Skip to content

Commit

Permalink
Migrate errors bar tests to typescript (#2741)
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot authored Jan 25, 2024
1 parent e800e1b commit af49e28
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ describe("components/victory-errorbar", () => {
it("renders an svg with the correct width and height", () => {
const { container } = render(<VictoryErrorBar />);
const svg = container.querySelector("svg");
expect(svg.style.width).toEqual("100%");
expect(svg.style.height).toEqual("100%");
expect(svg!.style.width).toEqual("100%");
expect(svg!.style.height).toEqual("100%");
});

it("renders an svg with the correct viewBox", () => {
const { container } = render(<VictoryErrorBar />);
const svg = container.querySelector("svg");
const viewBoxValue = `0 0 ${450} ${300}`;
expect(svg.getAttribute("viewBox")).toEqual(viewBoxValue);
expect(svg!.getAttribute("viewBox")).toEqual(viewBoxValue);
});

it("renders 4 errors", () => {
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("components/victory-errorbar", () => {
render(<VictoryErrorBar data={data} sortKey="x" {...defaultProps} />);
const xValues = screen
.getAllByTestId("error-bar")
.map((node) => parseInt(node.getAttribute("data-x")));
.map((node) => parseInt(node.getAttribute("data-x")!));
expect(xValues).toEqual([0, 1, 2, 3, 4]);
});

Expand All @@ -124,7 +124,7 @@ describe("components/victory-errorbar", () => {
);
const yValues = screen
.getAllByTestId("error-bar")
.map((node) => parseInt(node.getAttribute("data-y")));
.map((node) => parseInt(node.getAttribute("data-y")!));
expect(yValues).toEqual([4, 3, 2, 1, 0]);
});

Expand Down Expand Up @@ -1017,7 +1017,7 @@ describe("components/victory-errorbar", () => {
/>,
);
const svg = container.querySelector("svg");
fireEvent.click(svg);
fireEvent.click(svg!);
expect(clickHandler).toBeCalled();
});

Expand Down Expand Up @@ -1091,7 +1091,7 @@ describe("components/victory-errorbar", () => {
expect(g.getAttribute("aria-label")).toEqual(
`error bar chart, x ${data[i].x}`,
);
expect(parseInt(g.getAttribute("tabindex"), 10)).toEqual(i + 2);
expect(parseInt(g.getAttribute("tabindex")!, 10)).toEqual(i + 2);
});
});
});
Expand Down

1 comment on commit af49e28

@vercel
Copy link

@vercel vercel bot commented on af49e28 Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.