1+ import { TranslatePipe } from '@ngx-translate/core' ;
2+ import { MockComponents , MockPipe } from 'ng-mocks' ;
3+
4+ import { DynamicDialogConfig , DynamicDialogRef } from 'primeng/dynamicdialog' ;
5+
6+ import { signal } from '@angular/core' ;
17import { ComponentFixture , TestBed } from '@angular/core/testing' ;
28
9+ import { FileSelectDestinationComponent } from '@osf/shared/components/file-select-destination/file-select-destination.component' ;
10+ import { IconComponent } from '@osf/shared/components/icon/icon.component' ;
11+ import { LoadingSpinnerComponent } from '@osf/shared/components/loading-spinner/loading-spinner.component' ;
12+ import { CustomConfirmationService } from '@osf/shared/services/custom-confirmation.service' ;
13+ import { FilesService } from '@osf/shared/services/files.service' ;
14+ import { ToastService } from '@osf/shared/services/toast.service' ;
15+
16+ import { FilesSelectors } from '../../store' ;
17+
318import { ConfirmMoveFileDialogComponent } from './confirm-move-file-dialog.component' ;
419
5- describe ( 'ConfirmMoveFileDialogComponent' , ( ) => {
20+ import { OSFTestingModule } from '@testing/osf.testing.module' ;
21+ import { CustomConfirmationServiceMock } from '@testing/providers/custom-confirmation-provider.mock' ;
22+ import { provideMockStore } from '@testing/providers/store-provider.mock' ;
23+ import { ToastServiceMock } from '@testing/providers/toast-provider.mock' ;
24+
25+ describe ( 'ConfirmConfirmMoveFileDialogComponent' , ( ) => {
626 let component : ConfirmMoveFileDialogComponent ;
727 let fixture : ComponentFixture < ConfirmMoveFileDialogComponent > ;
828
29+ const mockFilesService = {
30+ moveFiles : jest . fn ( ) ,
31+ getMoveDialogFiles : jest . fn ( ) ,
32+ } ;
33+
934 beforeEach ( async ( ) => {
35+ const dialogRefMock = {
36+ close : jest . fn ( ) ,
37+ } ;
38+
39+ const dialogConfigMock = {
40+ data : { files : [ ] , destination : { name : 'files' } } ,
41+ } ;
42+
1043 await TestBed . configureTestingModule ( {
11- imports : [ ConfirmMoveFileDialogComponent ] ,
44+ imports : [
45+ ConfirmMoveFileDialogComponent ,
46+ OSFTestingModule ,
47+ ...MockComponents ( IconComponent , LoadingSpinnerComponent , FileSelectDestinationComponent ) ,
48+ MockPipe ( TranslatePipe ) ,
49+ ] ,
50+ providers : [
51+ { provide : DynamicDialogRef , useValue : dialogRefMock } ,
52+ { provide : DynamicDialogConfig , useValue : dialogConfigMock } ,
53+ { provide : FilesService , useValue : mockFilesService } ,
54+ { provide : ToastService , useValue : ToastServiceMock . simple ( ) } ,
55+ { provide : CustomConfirmationService , useValue : CustomConfirmationServiceMock . simple ( ) } ,
56+ provideMockStore ( {
57+ signals : [
58+ { selector : FilesSelectors . getMoveDialogFiles , value : signal ( [ ] ) } ,
59+ { selector : FilesSelectors . getProvider , value : signal ( null ) } ,
60+ ] ,
61+ } ) ,
62+ ] ,
1263 } ) . compileComponents ( ) ;
1364
1465 fixture = TestBed . createComponent ( ConfirmMoveFileDialogComponent ) ;
@@ -19,4 +70,14 @@ describe('ConfirmMoveFileDialogComponent', () => {
1970 it ( 'should create' , ( ) => {
2071 expect ( component ) . toBeTruthy ( ) ;
2172 } ) ;
73+
74+ it ( 'should initialize with correct properties' , ( ) => {
75+ expect ( component . config ) . toBeDefined ( ) ;
76+ expect ( component . dialogRef ) . toBeDefined ( ) ;
77+ expect ( component . files ) . toBeDefined ( ) ;
78+ } ) ;
79+
80+ it ( 'should get files from store' , ( ) => {
81+ expect ( component . files ( ) ) . toEqual ( [ ] ) ;
82+ } ) ;
2283} ) ;
0 commit comments