diff --git a/src/domain/usecases/MapDiseaseOutbreakToAlertsUseCase.ts b/src/domain/usecases/MapDiseaseOutbreakToAlertsUseCase.ts index aa48ba20..ab34c1d5 100644 --- a/src/domain/usecases/MapDiseaseOutbreakToAlertsUseCase.ts +++ b/src/domain/usecases/MapDiseaseOutbreakToAlertsUseCase.ts @@ -10,6 +10,11 @@ import { RTSL_ZEBRA_ALERTS_EVENT_TYPE_TEA_ID, } from "../../data/repositories/consts/DiseaseOutbreakConstants"; +type DiseaseOutbreakEventData = Pick< + DiseaseOutbreakEventBaseAttrs, + "dataSourceCode" | "hazardType" | "incidentStatus" | "suspectedDiseaseCode" +>; + const incidentDataSourceCode = "IBS"; export class MapDiseaseOutbreakToAlertsUseCase { @@ -17,7 +22,7 @@ export class MapDiseaseOutbreakToAlertsUseCase { public execute( diseaseOutbreakEventId: Id, - diseaseOutbreakEventData: DiseaseOutbreakEventBaseAttrs + diseaseOutbreakEventData: DiseaseOutbreakEventData ): FutureData { const { dataSourceCode, hazardType, suspectedDiseaseCode } = diseaseOutbreakEventData; const hazardTypeCode = hazardTypeCodeMap[hazardType]; diff --git a/src/domain/usecases/__tests__/MapDiseaseOutbreakToAlertsUseCase.spec.ts b/src/domain/usecases/__tests__/MapDiseaseOutbreakToAlertsUseCase.spec.ts new file mode 100644 index 00000000..6e02c0ea --- /dev/null +++ b/src/domain/usecases/__tests__/MapDiseaseOutbreakToAlertsUseCase.spec.ts @@ -0,0 +1,35 @@ +import { getTestCompositionRoot } from "../../../CompositionRoot"; + +describe("MapDiseaseOutbreakToAlertsUseCase", () => { + it("does not map disease outbreak to alerts if there is no event id", async () => { + const compositionRoot = getTestCompositionRoot(); + + compositionRoot.diseaseOutbreakEvent.mapDiseaseOutbreakEventToAlerts + .execute("", { + dataSourceCode: "EBS", + hazardType: "Biological:Human", + suspectedDiseaseCode: "", + incidentStatus: "Watch", + }) + .run( + () => fail("Should not reach here"), + error => expect(error.message).toBe("Disease Outbreak Event Id is required") + ); + }); + + it("maps disease outbreak to alerts", async () => { + const compositionRoot = getTestCompositionRoot(); + + compositionRoot.diseaseOutbreakEvent.mapDiseaseOutbreakEventToAlerts + .execute("123", { + dataSourceCode: "EBS", + hazardType: "Biological:Human", + suspectedDiseaseCode: "", + incidentStatus: "Watch", + }) + .run( + data => expect(data).toBeUndefined(), + () => fail("Should not reach here") + ); + }); +});