From 7f6acf065f78bd284a7e011cb4a33a770eff97b2 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Tue, 1 Sep 2020 17:52:30 -0700 Subject: [PATCH] test: add test for threshold --- packages/vx-threshold/test/Threshold.test.tsx | 63 ++++++++++++++++++- packages/vx-zoom/test/Zoom.test.tsx | 2 +- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/packages/vx-threshold/test/Threshold.test.tsx b/packages/vx-threshold/test/Threshold.test.tsx index b94e04eee..75bf495ce 100644 --- a/packages/vx-threshold/test/Threshold.test.tsx +++ b/packages/vx-threshold/test/Threshold.test.tsx @@ -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('', () => { + it('should be defined', () => { expect(Threshold).toBeDefined(); }); + + it('should render the path', () => { + const wrapper = render( + + 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, + }} + /> + , + ); + expect(wrapper.find('g.vx-threshold')).toHaveLength(1); + expect(wrapper.find('path')).toHaveLength(4); + }); + + it('supports accessors for clipping', () => { + const wrapper = render( + + 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, + }} + /> + , + ); + expect(wrapper.find('g.vx-threshold')).toHaveLength(1); + expect(wrapper.find('path')).toHaveLength(4); + }); }); diff --git a/packages/vx-zoom/test/Zoom.test.tsx b/packages/vx-zoom/test/Zoom.test.tsx index db6ca4e3c..68364ac7a 100644 --- a/packages/vx-zoom/test/Zoom.test.tsx +++ b/packages/vx-zoom/test/Zoom.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render } from 'enzyme'; import { Zoom, inverseMatrix } from '../src'; -describe('Zoom', () => { +describe('', () => { it('should be defined', () => { expect(Zoom).toBeDefined(); });