Skip to content

Commit

Permalink
Remove lowercasing in feature flag mock
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbrown committed Nov 2, 2024
1 parent affbd70 commit 1c219c1
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions frontend/src/app/testQueue/TestCard/TestCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,11 @@ jest.mock("../../TelemetryService", () => ({
getAppInsights: jest.fn(),
}));

const mockDiseaseEnabledFlag = (
diseaseName: string,
skipLowercase: boolean = false
) =>
const mockDiseaseEnabledFlag = (diseaseName: string) =>
jest
.spyOn(flaggedMock, "useFeature")
.mockImplementation((flagName: string) => {
// to handle casing of Hepatitis-C as hepatitisC
if (skipLowercase) {
return flagName === `${diseaseName}Enabled`;
}
return flagName === `${diseaseName.toLowerCase()}Enabled`;
return flagName === `${diseaseName}Enabled`;
});

const mockNavigate = jest.fn();
Expand Down Expand Up @@ -1132,7 +1125,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for HIV when an HIV device is chosen", async function () {
mockDiseaseEnabledFlag("HIV");
mockDiseaseEnabledFlag("hiv");

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
Expand All @@ -1152,7 +1145,7 @@ describe("TestCard", () => {
});

it("shows required HIV AOE questions when a positive HIV result is present", async function () {
mockDiseaseEnabledFlag("HIV");
mockDiseaseEnabledFlag("hiv");

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.POSITIVE),
Expand Down Expand Up @@ -1182,7 +1175,7 @@ describe("TestCard", () => {
});

it("hides AOE questions when there is no positive HIV result", async function () {
mockDiseaseEnabledFlag("HIV");
mockDiseaseEnabledFlag("hiv");

const mocks = [
generateEditQueueMock(MULTIPLEX_DISEASES.HIV, TEST_RESULTS.UNKNOWN),
Expand All @@ -1209,7 +1202,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for Syphilis when a syphilis device is chosen", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const mocks = [
generateEditQueueMock(
Expand All @@ -1229,7 +1222,7 @@ describe("TestCard", () => {
});

it("shows required syphilis AOE questions when a positive syphilis result is present", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1269,7 +1262,7 @@ describe("TestCard", () => {
});

it("hides AOE questions when there is no positive syphilis result", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1325,7 +1318,7 @@ describe("TestCard", () => {
});

it("shows radio buttons for Hepatitis C when a hepatitis c device is chosen", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand All @@ -1345,7 +1338,7 @@ describe("TestCard", () => {
});

it("shows required Hepatitis-C AOE questions when a positive Hepatitis-C result is present", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1397,7 +1390,7 @@ describe("TestCard", () => {
});

it("hides AOE questions when there is no positive Hepatitis-C result", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const mocks = [
generateEditQueueMock(
Expand Down Expand Up @@ -1443,7 +1436,7 @@ describe("TestCard", () => {
});

it("checks that Hep C submission only works if AOE questions are valid", async function () {
mockDiseaseEnabledFlag("hepatitisC", true);
mockDiseaseEnabledFlag("hepatitisC");

const { user } = await renderQueueItem({ mocks: updateHepCAoeMocks });
const deviceDropdown = await getDeviceTypeDropdown();
Expand Down Expand Up @@ -1494,7 +1487,7 @@ describe("TestCard", () => {
});

it("checks that submission only works if AOE questions are valid", async function () {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");

const { user } = await renderQueueItem({ mocks: updateSyphilisAoeMocks });
const deviceDropdown = await getDeviceTypeDropdown();
Expand Down Expand Up @@ -1556,7 +1549,7 @@ describe("TestCard", () => {
});

it("checks that checking has symptom requires onset date and selection", async () => {
mockDiseaseEnabledFlag("Syphilis");
mockDiseaseEnabledFlag("syphilis");
const mocks = [...updateSyphilisAoeMocks];

const { user } = await renderQueueItem({ mocks });
Expand Down

0 comments on commit 1c219c1

Please sign in to comment.