I have a controller that makes a GET request to the server, then based on the response from the server, makes
another GET request.
I have the following in my unit test:
const getSdRequest = httpClient.expectOne('/api/structureDefinition/test');
expect(getSdRequest.request.method).toBe('GET');
getSdRequest.flush({
resource: {
resourceType: 'StructureDefinition',
id: 'test',
type: 'Composition',
baseDefinition: 'http://hl7.org/fhir/StructureDefinition/Composition'
}
});
const getBaseRequest = httpClient.expectOne('/api/structureDefinition/base');
expect(getBaseRequest.request.method).toBe('GET');
getBaseRequest.flush({
resourceType: 'StructureDefinition',
id: 'Composition'
});
When the test runs, I get the following errors:
StructureDefinitionComponent › should init
Expected one matching request for criteria "Match URL: /api/structureDefinition/base", found none.
StructureDefinitionComponent › should init
Expected no open requests, found 1: GET /api/structureDefinition/base
As you can see, I am expecting /api/structureDefinition/base, but the test errors that it's not found, and then another error that it was found.
Does anyone know what's going on here?