Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed May 16, 2024
1 parent 68e4ca1 commit 8149d78
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions frontend/src/app/testQueue/TestCardForm/TestCardForm.utils.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TestFormState } from "./TestCardFormReducer";
import {
AOEFormOption,
AoeValidationErrorMessages,
generateAoeValidationState,
} from "./TestCardForm.utils";
import { devicesMap } from "./testUtils/testConstants";
Expand Down Expand Up @@ -38,14 +39,14 @@ describe("TestCardForm.utils", () => {
it("should correctly evaluate whether COVID AOE answers are complete", () => {
expect(
generateAoeValidationState(incompleteState, AOEFormOption.COVID)
).toEqual(false);
).toEqual(AoeValidationErrorMessages.INCOMPLETE);

expect(
generateAoeValidationState(
completeStateWithSymptoms,
AOEFormOption.COVID
)
).toEqual(true);
).toEqual(AoeValidationErrorMessages.COMPLETE);

const completeStateNoSymptoms: TestFormState = {
...incompleteState,
Expand All @@ -60,22 +61,26 @@ describe("TestCardForm.utils", () => {

expect(
generateAoeValidationState(completeStateNoSymptoms, AOEFormOption.COVID)
).toEqual(true);
).toEqual(AoeValidationErrorMessages.COMPLETE);

const partialIncompleteState: TestFormState = {
...incompleteState,
aoeResponses: {
pregnancy: "60001007",
noSymptoms: false,
symptoms: null,
symptomOnset: undefined,
genderOfSexualPartners: null,
},
};
const noSymptomsFalseButWithoutRequiredSymptomSubquestionsState: TestFormState =
{
...incompleteState,
aoeResponses: {
pregnancy: "60001007",
noSymptoms: false,
symptoms: null,
symptomOnset: undefined,
genderOfSexualPartners: null,
},
};

expect(
generateAoeValidationState(partialIncompleteState, AOEFormOption.COVID)
).toEqual(false);
generateAoeValidationState(
noSymptomsFalseButWithoutRequiredSymptomSubquestionsState,
AOEFormOption.COVID
)
).toEqual(AoeValidationErrorMessages.SYMPTOM_VALIDATION_ERROR);

const incompleteStateHasSymptomsButNoSymptomMap: TestFormState = {
...incompleteState,
Expand All @@ -93,7 +98,7 @@ describe("TestCardForm.utils", () => {
incompleteStateHasSymptomsButNoSymptomMap,
AOEFormOption.COVID
)
).toEqual(false);
).toEqual(AoeValidationErrorMessages.SYMPTOM_VALIDATION_ERROR);
});

it("should return false if HIV questions are unanswered", () => {
Expand All @@ -102,7 +107,7 @@ describe("TestCardForm.utils", () => {
};
expect(
generateAoeValidationState(positiveHIVState, AOEFormOption.HIV)
).toEqual(false);
).toEqual(AoeValidationErrorMessages.INCOMPLETE);
});

it("should return true when HIV positive is selected and questions are answered", () => {
Expand All @@ -114,7 +119,7 @@ describe("TestCardForm.utils", () => {
positiveHIVStateCompleteAOE,
AOEFormOption.HIV
)
).toEqual(true);
).toEqual(AoeValidationErrorMessages.COMPLETE);
});
});
});

0 comments on commit 8149d78

Please sign in to comment.