Skip to content

Commit

Permalink
Show Hep C guidance for non-positive results too
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbrown committed Oct 29, 2024
1 parent 477fe71 commit 59ebd9d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import { render, screen } from "@testing-library/react";
import { cloneDeep } from "lodash";

import "../../../i18n";

import { MULTIPLEX_DISEASES, TEST_RESULTS } from "../../testResults/constants";

import HepatitisCResultGuidance from "./HepatitisCResultGuidance";

describe("HepatitisCResultGuidance", () => {
const mockResultTemplate = {
disease: {
name: MULTIPLEX_DISEASES.HEPATITIS_C,
},
testResult: TEST_RESULTS.POSITIVE,
} as MultiplexResult;

it("displays guidance for a positive Hepatitis-C result", () => {
const { container } = render(
<HepatitisCResultGuidance result={mockResultTemplate} />
);
it("displays guidance for a Hepatitis-C result", () => {
const { container } = render(<HepatitisCResultGuidance />);
expect(screen.getByText("For Hepatitis-C:")).toBeInTheDocument();
expect(container).toMatchSnapshot();
});

const nonPositiveCases = [
TEST_RESULTS.NEGATIVE,
TEST_RESULTS.UNDETERMINED,
TEST_RESULTS.UNKNOWN,
];

test.each(nonPositiveCases)(
"displays no Hepatitis-C guidance for %p result",
(testResult) => {
const mockResult = cloneDeep(mockResultTemplate);
mockResult.testResult = testResult;
render(<HepatitisCResultGuidance result={mockResult} />);
expect(screen.queryByText("For Hepatitis-C:")).not.toBeInTheDocument();
}
);
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from "react";
import { Trans, useTranslation } from "react-i18next";

import { TEST_RESULTS } from "../../testResults/constants";

import { ResultGuidanceProps } from "./ResultsGuidance";

const PositiveHepatitisCResultInfo = () => {
const HepatitisCResultGuidance = () => {
const { t } = useTranslation();

return (
Expand All @@ -32,10 +28,4 @@ const PositiveHepatitisCResultInfo = () => {
);
};

const HepatitisCResultGuidance = ({ result }: ResultGuidanceProps) => {
const hasPositiveHepatitisCResult =
result.testResult === TEST_RESULTS.POSITIVE;
return <>{hasPositiveHepatitisCResult && <PositiveHepatitisCResultInfo />}</>;
};

export default HepatitisCResultGuidance;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HepatitisCResultGuidance displays guidance for a positive Hepatitis-C result 1`] = `
exports[`HepatitisCResultGuidance displays guidance for a Hepatitis-C result 1`] = `
<div>
<p
class="text-bold sr-guidance-heading"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/utils/testResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const getGuidanceForResults = (

match = getResultForDisease(results, MULTIPLEX_DISEASES.HEPATITIS_C);
if (match) {
guidance.push(<HepatitisCResultGuidance result={match} />);
guidance.push(<HepatitisCResultGuidance />);
}

return guidance;
Expand Down

0 comments on commit 59ebd9d

Please sign in to comment.