Skip to content

Commit

Permalink
test: add test for threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Sep 2, 2020
1 parent 76548a0 commit 7f6acf0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
63 changes: 61 additions & 2 deletions packages/vx-threshold/test/Threshold.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,66 @@
import React from 'react';
import { render } from 'enzyme';
import { Threshold } from '../src';

describe('Threshold', () => {
test('it should be defined', () => {
const data = [
{ x: 1, y0: 6, y1: 10 },
{ x: 2, y0: 7, y1: 11 },
];

describe('<Threshold />', () => {
it('should be defined', () => {
expect(Threshold).toBeDefined();
});

it('should render the path', () => {
const wrapper = render(
<svg>
<Threshold
id={`${Math.random()}`}
data={data}
x={d => d.x}
y0={d => d.y0}
y1={d => d.y1}
clipAboveTo={0}
clipBelowTo={100}
belowAreaProps={{
fill: 'violet',
fillOpacity: 0.4,
}}
aboveAreaProps={{
fill: 'green',
fillOpacity: 0.4,
}}
/>
</svg>,
);
expect(wrapper.find('g.vx-threshold')).toHaveLength(1);
expect(wrapper.find('path')).toHaveLength(4);
});

it('supports accessors for clipping', () => {
const wrapper = render(
<svg>
<Threshold
id={`${Math.random()}`}
data={data}
x={d => d.x}
y0={d => d.y0}
y1={d => d.y1}
clipAboveTo={() => 0}
clipBelowTo={() => 100}
belowAreaProps={{
fill: 'violet',
fillOpacity: 0.4,
}}
aboveAreaProps={{
fill: 'green',
fillOpacity: 0.4,
}}
/>
</svg>,
);
expect(wrapper.find('g.vx-threshold')).toHaveLength(1);
expect(wrapper.find('path')).toHaveLength(4);
});
});
2 changes: 1 addition & 1 deletion packages/vx-zoom/test/Zoom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render } from 'enzyme';
import { Zoom, inverseMatrix } from '../src';

describe('Zoom', () => {
describe('<Zoom />', () => {
it('should be defined', () => {
expect(Zoom).toBeDefined();
});
Expand Down

0 comments on commit 7f6acf0

Please sign in to comment.