@@ -6,7 +6,7 @@ jest.mock('resize-observer-polyfill');
66// @ts -ignore
77import { triggerResizeObserver } from 'resize-observer-polyfill' ;
88import ErrorBoundary from 'react-error-boundary' ;
9- import { ChartProps , SuperChart } from '../../src' ;
9+ import { SuperChart } from '../../src' ;
1010import RealSuperChart from '../../src/components/SuperChart' ;
1111import { ChartKeys , DiligentChartPlugin , BuggyChartPlugin } from './MockChartPlugins' ;
1212import promiseTimeout from './promiseTimeout' ;
@@ -97,47 +97,15 @@ describe('SuperChart', () => {
9797 } ) ;
9898 } ) ;
9999
100- describe ( 'supports multiple way of specifying chartProps' , ( ) => {
101- it ( 'chartProps is instanceof ChartProps' , ( ) => {
102- const wrapper = mount (
103- < SuperChart
104- chartType = { ChartKeys . DILIGENT }
105- chartProps = { new ChartProps ( { width : 20 , height : 20 } ) }
106- /> ,
107- ) ;
108-
109- return promiseTimeout ( ( ) => {
110- const renderedWrapper = wrapper . render ( ) ;
111- expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
112- expectDimension ( renderedWrapper , 20 , 20 ) ;
113- } ) ;
114- } ) ;
115- it ( 'chartProps is ChartPropsConfig' , ( ) => {
116- const wrapper = mount (
117- < SuperChart chartType = { ChartKeys . DILIGENT } chartProps = { { width : 201 , height : 202 } } /> ,
118- ) ;
100+ it ( 'passes the props to renderer correctly' , ( ) => {
101+ const wrapper = mount (
102+ < SuperChart chartType = { ChartKeys . DILIGENT } width = { 101 } height = { 118 } formData = { { abc : 1 } } /> ,
103+ ) ;
119104
120- return promiseTimeout ( ( ) => {
121- const renderedWrapper = wrapper . render ( ) ;
122- expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
123- expectDimension ( renderedWrapper , 201 , 202 ) ;
124- } ) ;
125- } ) ;
126- it ( 'fields of chartProps are listed as props of SuperChart' , ( ) => {
127- const wrapper = mount (
128- < SuperChart
129- chartType = { ChartKeys . DILIGENT }
130- width = { 101 }
131- height = { 118 }
132- formData = { { abc : 1 } }
133- /> ,
134- ) ;
135-
136- return promiseTimeout ( ( ) => {
137- const renderedWrapper = wrapper . render ( ) ;
138- expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
139- expectDimension ( renderedWrapper , 101 , 118 ) ;
140- } ) ;
105+ return promiseTimeout ( ( ) => {
106+ const renderedWrapper = wrapper . render ( ) ;
107+ expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
108+ expectDimension ( renderedWrapper , 101 , 118 ) ;
141109 } ) ;
142110 } ) ;
143111
@@ -191,33 +159,6 @@ describe('SuperChart', () => {
191159 const wrapper = mount ( < SuperChart chartType = { ChartKeys . DILIGENT } debounceTime = { 1 } /> ) ;
192160 triggerResizeObserver ( ) ;
193161
194- return promiseTimeout ( ( ) => {
195- const renderedWrapper = wrapper . render ( ) ;
196- expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
197- expectDimension ( renderedWrapper , 300 , 400 ) ;
198- } , 100 ) ;
199- } ) ;
200- it ( 'works when width and height are inside chartProps' , ( ) => {
201- const wrapper = mount (
202- < SuperChart
203- chartType = { ChartKeys . DILIGENT }
204- debounceTime = { 1 }
205- chartProps = { { width : 123 , height : 456 } }
206- /> ,
207- ) ;
208-
209- return promiseTimeout ( ( ) => {
210- const renderedWrapper = wrapper . render ( ) ;
211- expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
212- expectDimension ( renderedWrapper , 123 , 456 ) ;
213- } , 100 ) ;
214- } ) ;
215- it ( 'works when there is chartProps but still no width and height' , ( ) => {
216- const wrapper = mount (
217- < SuperChart chartType = { ChartKeys . DILIGENT } debounceTime = { 1 } chartProps = { { } } /> ,
218- ) ;
219- triggerResizeObserver ( ) ;
220-
221162 return promiseTimeout ( ( ) => {
222163 const renderedWrapper = wrapper . render ( ) ;
223164 expect ( renderedWrapper . find ( 'div.test-component' ) ) . toHaveLength ( 1 ) ;
0 commit comments