2024-01-17 14:29:28 -07:00
|
|
|
import "@testing-library/jest-native/extend-expect";
|
2024-02-03 20:30:00 -07:00
|
|
|
import { render } from "@testing-library/react-native";
|
|
|
|
import React from "react";
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-06 15:24:49 -07:00
|
|
|
import ChartLabel from "../../src/component/charts/chart-label/chart-label";
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
describe("ChartLabel Component Tests", () => {
|
|
|
|
const mockData = {
|
|
|
|
yLabels: [
|
|
|
|
{ displayName: "Shots Taken", axis: "LEFT" as "LEFT", color: "#598EBB" },
|
|
|
|
{
|
|
|
|
displayName: "Make Percentage",
|
|
|
|
axis: "RIGHT" as "RIGHT",
|
|
|
|
color: "#F2D4BC",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
title: "Shots Taken / Make Percentage by Cut Angle",
|
|
|
|
};
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
it("should render the correct labels given yLabels", () => {
|
|
|
|
const { getByText } = render(
|
|
|
|
<ChartLabel title={mockData.title} yLabels={mockData.yLabels} />,
|
|
|
|
);
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
mockData.yLabels.forEach((label) => {
|
|
|
|
expect(getByText(label.displayName)).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
it("should render the correct number of label boxes", () => {
|
|
|
|
const { getAllByText } = render(
|
|
|
|
<ChartLabel title={mockData.title} yLabels={mockData.yLabels} />,
|
|
|
|
);
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
// Assuming displayName is unique and used only for labels
|
|
|
|
const labelElements = mockData.yLabels
|
|
|
|
.map((label) => getAllByText(label.displayName))
|
|
|
|
.flat();
|
2024-01-17 14:29:28 -07:00
|
|
|
|
2024-02-03 20:23:31 -07:00
|
|
|
expect(labelElements.length).toBe(mockData.yLabels.length);
|
|
|
|
});
|
2024-01-17 14:29:28 -07:00
|
|
|
});
|