railbird-gql/test/component/chart-view.test.tsx

32 lines
924 B
TypeScript
Raw Normal View History

2024-02-03 20:30:00 -07:00
import "@testing-library/jest-native/extend-expect";
import { render } from "@testing-library/react-native";
import React from "react";
import { Text } from "react-native";
2024-01-15 14:02:51 -07:00
import ChartView from "../../component/charts/chart-view";
2024-01-15 14:02:51 -07:00
describe("ChartView Component Tests", () => {
it("applies the passed style prop correctly", () => {
const testStyle = { backgroundColor: "blue", padding: 10 };
const { getByTestId } = render(
<ChartView style={testStyle} testID="chart-view">
<Text>Test Child</Text>
</ChartView>,
);
2024-01-15 14:02:51 -07:00
const chartView = getByTestId("chart-view");
expect(chartView.props.style).toEqual(expect.arrayContaining([testStyle]));
});
2024-01-15 14:02:51 -07:00
it("renders children correctly", () => {
const { getByText } = render(
<ChartView>
<Text testID="child-text">Child Component</Text>
</ChartView>,
);
const childText = getByText("Child Component");
expect(childText).toBeTruthy();
});
});