From ecc10a24e378f252a8e63227c242ab3271f3e862 Mon Sep 17 00:00:00 2001 From: Natalie Martin Date: Tue, 5 Mar 2024 16:28:42 -0700 Subject: [PATCH] Fix failing MainComponent test This test fails sometimes because the test module is provided with an undefined MockDragService. Initialize this mock before setting up providers so that this test passes regardless of which order tests are run in. --- .../components/main/main.component.spec.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/core/components/main/main.component.spec.ts b/src/app/core/components/main/main.component.spec.ts index 1acfe4ab6..9ea857318 100644 --- a/src/app/core/components/main/main.component.spec.ts +++ b/src/app/core/components/main/main.component.spec.ts @@ -45,6 +45,16 @@ describe('MainComponent', () => { let mockDragEvents: Subject; async function init(authResponseData = defaultAuthData) { + mockDragEvents = new Subject(); + mockDragService = jasmine.createSpyObj('DragService', [ + 'getDestinationFromDropTarget', + 'events', + ]); + mockDragService.events.and.returnValue(mockDragEvents.asObservable()); + mockDragService.getDestinationFromDropTarget.and.returnValue( + new FolderVO({ type: 'type.folder.public' }) + ); + const config = cloneDeep(Testing.BASE_TEST_CONFIG); config.imports.push(SharedModule); @@ -83,16 +93,6 @@ describe('MainComponent', () => { promptService = TestBed.inject(PromptService); spyOn(promptService, 'confirm'); - mockDragEvents = new Subject(); - mockDragService = jasmine.createSpyObj('DragService', [ - 'getDestinationFromDropTarget', - 'events', - ]); - mockDragService.events.and.returnValue(mockDragEvents.asObservable()); - mockDragService.getDestinationFromDropTarget.and.returnValue( - new FolderVO({ type: 'type.folder.public' }) - ); - fixture = TestBed.createComponent(MainComponent); component = fixture.componentInstance; fixture.detectChanges();