update test to be for the container rather than component

This commit is contained in:
Loewy
2024-02-13 14:10:05 -08:00
parent 3eab510f5a
commit 4e7046bd28
4 changed files with 60 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
import { render } from "@testing-library/react-native";
import React from "react";
import ChartContainer from "../../src/component/charts/container/chart-container";
import LineGraph from "../../src/component/charts/line-graph/line-graph";
import { line_chart_two_y_data } from "../mock/charts/mock-data";
describe("ChartContainer Component Tests", () => {
it("renders correctly with data -- line graph", () => {
const { getByTestId } = render(
<ChartContainer
data={line_chart_two_y_data}
testID="1"
ChartComponent={LineGraph}
/>,
);
expect(getByTestId(`chart-container-1`)).toBeTruthy();
});
it("does not render without data props", () => {
// Have to ts-ignore to test null data conditions
// @ts-ignore
const { queryByTestId } = render(<ChartContainer testID="2" />);
expect(queryByTestId(`chart-container-2`)).toBeNull();
});
});

View File

@@ -1,20 +0,0 @@
import { render } from "@testing-library/react-native";
import React from "react";
import LineGraph from "../../src/component/charts/line-graph/line-graph";
import { line_chart_two_y_data } from "../mock/charts/mock-data";
describe("LineGraph Component Tests", () => {
it("renders correctly with data", () => {
const { getByTestId } = render(
<LineGraph data={line_chart_two_y_data} testID="1" />,
);
expect(getByTestId(`line-graph-1`)).toBeTruthy();
});
it("does not render without data", () => {
// Have to ts-ignore to test null data conditions
// @ts-ignore
const { queryByTestId } = render(<LineGraph testID="2" />);
expect(queryByTestId(`line-graph-2`)).toBeNull();
});
});