Add tests and fix tests

This commit is contained in:
Yana De Pauw
2021-03-04 17:10:01 +01:00
parent d07f44ac41
commit b18f9c7c9f
47 changed files with 937 additions and 454 deletions

View File

@@ -115,15 +115,22 @@ describe('SubmissionImportExternalComponent test suite', () => {
spyOn(compAsAny.routeService, 'getQueryParameterValue').and.returnValues(observableOf('source'), observableOf('dummy'));
fixture.detectChanges();
expect(compAsAny.retrieveExternalSources).toHaveBeenCalledWith('source', 'dummy');
expect(compAsAny.retrieveExternalSources).toHaveBeenCalled();
});
it('Should call \'getExternalSourceEntries\' properly', () => {
comp.routeData = { sourceId: '', query: '' };
scheduler.schedule(() => compAsAny.retrieveExternalSources('orcidV2', 'test'));
scheduler.flush();
spyOn(routeServiceStub, 'getQueryParameterValue').and.callFake((param) => {
if (param === 'source') {
return observableOf('orcidV2');
} else if (param === 'query') {
return observableOf('test');
}
return observableOf({});
});
fixture.detectChanges();
expect(comp.routeData).toEqual({ sourceId: 'orcidV2', query: 'test' });
expect(comp.isLoading$.value).toBe(false);
expect(compAsAny.externalService.getExternalSourceEntries).toHaveBeenCalled();
});