Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IPWright83 committed Jul 6, 2023
1 parent d11d198 commit 7031fa6
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
import { Provider, useSelector } from "react-redux";
import React from "react";

import { renderChart, wait } from "../../testUtils";
import { chartSelectors, IState } from "../../store";
import { createMockStore, renderChart, wait } from "../../testUtils";
import { themes } from "../../themes";

import { RectangleClipPath } from "./RectangleClipPath";

describe("RectangleClipPath", () => {
const Circle = ({ clipPath }: { clipPath?: string }) => {
return <circle clipPath={`url(#${clipPath})`} cx={0} cy={0} r={100} fill="red" />;
const store = createMockStore({
chart: {
dimensions: {
width: 800,
height: 400,
},
theme: themes.light,
},
event: {
mouse: { x: 150, y: 200 },
},
});

const Circle = () => {
const plotClipPath = useSelector((s: IState) => chartSelectors.plotClipPath(s));

return <circle clipPath={`url(#${plotClipPath})`} cx={0} cy={0} r={100} fill="red" />;
};

it("renders correctly", async () => {
const { asFragment } = await renderChart({
children: (
<RectangleClipPath>
<Provider store={store}>
<RectangleClipPath />
<Circle />
</RectangleClipPath>
</Provider>
),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ exports[`RectangleClipPath renders correctly 1`] = `
<svg>
<defs>
<clippath
id="clip-path-"
id="clip-path-test"
>
<rect
height="200"
width="200"
height="400"
width="800"
x="0"
y="0"
/>
</clippath>
</defs>
<circle
clip-path="url(#clip-path-)"
clip-path="url(#clip-path-test)"
cx="0"
cy="0"
fill="red"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Area using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot area"
clip-path="url(#clip-path-test)"
>
<path
class="area"
Expand All @@ -25,6 +26,7 @@ exports[`Area using SVG should skip rendering if there is no x scale avaliable 1
<svg>
<g
class="g-plot area"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -35,6 +37,7 @@ exports[`Area using SVG should skip rendering if there is no y scale avaliable 1
<svg>
<g
class="g-plot area"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`StackedArea using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-area"
clip-path="url(#clip-path-test)"
>
<path
class="area"
Expand All @@ -26,6 +27,7 @@ exports[`StackedArea using SVG should skip rendering if there is no x scale aval
<svg>
<g
class="g-plot stacked-area"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -36,6 +38,7 @@ exports[`StackedArea using SVG should skip rendering if there is no y scale aval
<svg>
<g
class="g-plot stacked-area"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Areas Multiple Series using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot area"
clip-path="url(#clip-path-test)"
>
<path
class="area"
Expand All @@ -18,6 +19,7 @@ exports[`Areas Multiple Series using SVG should render correctly 1`] = `
</g>
<g
class="g-plot area"
clip-path="url(#clip-path-test)"
>
<path
class="area"
Expand All @@ -38,6 +40,7 @@ exports[`Areas Stacked using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-area"
clip-path="url(#clip-path-test)"
>
<path
class="area"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Bar using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot bar"
clip-path="url(#clip-path-test)"
>
<rect
class="bar"
Expand Down Expand Up @@ -32,6 +33,7 @@ exports[`Bar using SVG should skip rendering if there is no x scale avaliable 1`
<svg>
<g
class="g-plot bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -42,6 +44,7 @@ exports[`Bar using SVG should skip rendering if there is no y scale avaliable 1`
<svg>
<g
class="g-plot bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`GroupedColumn using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot grouped-bar"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`GroupedColumn using SVG should skip rendering if there is no x scale av
<svg>
<g
class="g-plot grouped-bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -62,6 +64,7 @@ exports[`GroupedColumn using SVG should skip rendering if there is no y scale av
<svg>
<g
class="g-plot grouped-bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`StackedBar using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-bar"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`StackedBar using SVG should skip rendering if there is no x scale avali
<svg>
<g
class="g-plot stacked-bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -62,6 +64,7 @@ exports[`StackedBar using SVG should skip rendering if there is no y scale avali
<svg>
<g
class="g-plot stacked-bar"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Bars Grouped using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot grouped-bar"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`Bars Stacked using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-bar"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Column using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot column"
clip-path="url(#clip-path-test)"
>
<rect
class="column"
Expand Down Expand Up @@ -32,6 +33,7 @@ exports[`Column using SVG should skip rendering if there is no x scale avaliable
<svg>
<g
class="g-plot column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -42,6 +44,7 @@ exports[`Column using SVG should skip rendering if there is no y scale avaliable
<svg>
<g
class="g-plot column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`GroupedColumn using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot grouped-column"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`GroupedColumn using SVG should skip rendering if there is no x scale av
<svg>
<g
class="g-plot grouped-column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -62,6 +64,7 @@ exports[`GroupedColumn using SVG should skip rendering if there is no y scale av
<svg>
<g
class="g-plot grouped-column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`StackedColumn using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-column"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`StackedColumn using SVG should skip rendering if there is no x scale av
<svg>
<g
class="g-plot stacked-column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -62,6 +64,7 @@ exports[`StackedColumn using SVG should skip rendering if there is no y scale av
<svg>
<g
class="g-plot stacked-column"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Columns Grouped using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot grouped-column"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down Expand Up @@ -52,6 +53,7 @@ exports[`Columns Stacked using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot stacked-column"
clip-path="url(#clip-path-test)"
>
<g>
<rect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Line using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot line"
clip-path="url(#clip-path-test)"
>
<path
class="line"
Expand All @@ -26,6 +27,7 @@ exports[`Line using SVG should skip rendering if there is no x scale avaliable 1
<svg>
<g
class="g-plot line"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -36,6 +38,7 @@ exports[`Line using SVG should skip rendering if there is no y scale avaliable 1
<svg>
<g
class="g-plot line"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Lines Multiple Series using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot line"
clip-path="url(#clip-path-test)"
>
<path
class="line"
Expand All @@ -19,6 +20,7 @@ exports[`Lines Multiple Series using SVG should render correctly 1`] = `
</g>
<g
class="g-plot line"
clip-path="url(#clip-path-test)"
>
<path
class="line"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Scatter using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot scatter"
clip-path="url(#clip-path-test)"
>
<circle
class="scatter-point"
Expand All @@ -30,6 +31,7 @@ exports[`Scatter using SVG should skip rendering if there is no x scale avaliabl
<svg>
<g
class="g-plot scatter"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand All @@ -40,6 +42,7 @@ exports[`Scatter using SVG should skip rendering if there is no y scale avaliabl
<svg>
<g
class="g-plot scatter"
clip-path="url(#clip-path-test)"
/>
</svg>
</DocumentFragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Scatters using SVG should render correctly 1`] = `
<svg>
<g
class="g-plot scatter"
clip-path="url(#clip-path-test)"
>
<circle
class="scatter-point"
Expand All @@ -23,6 +24,7 @@ exports[`Scatters using SVG should render correctly 1`] = `
</g>
<g
class="g-plot scatter"
clip-path="url(#clip-path-test)"
>
<circle
class="scatter-point"
Expand Down
Loading

0 comments on commit 7031fa6

Please sign in to comment.