1
0

[DURACOM-307] fix tests

This commit is contained in:
FrancescoMolinaro
2025-02-06 17:53:31 +01:00
parent dc70ec0ef0
commit b1eb4a8bf9
8 changed files with 26 additions and 28 deletions

View File

@@ -6,7 +6,9 @@ import {
} from '@angular/core';
import {
ComponentFixture,
fakeAsync,
TestBed,
tick,
waitForAsync,
} from '@angular/core/testing';
import {
@@ -210,6 +212,11 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
formOperationsService = TestBed.inject(SectionFormOperationsService);
collectionDataService = TestBed.inject(CollectionDataService);
compAsAny.pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionObject.id);
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
});
afterEach(() => {
@@ -219,18 +226,13 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
});
// Test initialisation of the submission section
it('Should init section properly', () => {
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
it('Should init section properly', fakeAsync(() => {
spyOn(comp, 'getSectionStatus').and.returnValue(observableOf(true));
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({ potentialDuplicates: duplicates }));
expect(comp.isLoading).toBeTruthy();
comp.onSectionInit();
fixture.detectChanges();
tick(100);
expect(comp.isLoading).toBeFalsy();
});
}));
// The following tests look for proper logic in the getSectionStatus() implementation
// These are very simple as we don't really have a 'false' state unless we're still loading
@@ -241,7 +243,7 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
}));
});
it('Should return FALSE', () => {
compAsAny.isLoadin = true;
compAsAny.isLoading = true;
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
a: false,
}));