From af49e2890a975263d0334c2129078212a4fb9c2d Mon Sep 17 00:00:00 2001 From: Charlie Brown Date: Thu, 25 Jan 2024 08:14:26 -0600 Subject: [PATCH] Migrate errors bar tests to typescript (#2741) --- ...rrorbars.test.js => victory-errorbars.test.tsx} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename packages/victory-errorbar/src/{victory-errorbars.test.js => victory-errorbars.test.tsx} (98%) diff --git a/packages/victory-errorbar/src/victory-errorbars.test.js b/packages/victory-errorbar/src/victory-errorbars.test.tsx similarity index 98% rename from packages/victory-errorbar/src/victory-errorbars.test.js rename to packages/victory-errorbar/src/victory-errorbars.test.tsx index c2bf98bad..a3425da47 100644 --- a/packages/victory-errorbar/src/victory-errorbars.test.js +++ b/packages/victory-errorbar/src/victory-errorbars.test.tsx @@ -36,15 +36,15 @@ describe("components/victory-errorbar", () => { it("renders an svg with the correct width and height", () => { const { container } = render(); 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(); 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", () => { @@ -104,7 +104,7 @@ describe("components/victory-errorbar", () => { render(); 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]); }); @@ -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]); }); @@ -1017,7 +1017,7 @@ describe("components/victory-errorbar", () => { />, ); const svg = container.querySelector("svg"); - fireEvent.click(svg); + fireEvent.click(svg!); expect(clickHandler).toBeCalled(); }); @@ -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); }); }); });