11import React from 'react' ;
22import { render , fireEvent } from '@testing-library/react' ;
3- import renderer from 'react-test-renderer' ;
43import BarGraph from './bar' ;
54import { staggeredData } from '../helpers/helpersData' ;
6- import { ResponsiveBar } from '@nivo/bar' ;
75import helpers from './helpers/helpers' ;
86
97class ResizeObserver {
@@ -23,46 +21,31 @@ describe('BarGraph component', () => {
2321 const { queryByTestId } = render ( < BarGraph graphData = { staggeredData } graphIndex = "year" valueKeys = { [ 'value' ] } /> ) ;
2422 expect ( queryByTestId ( 'barGraph' ) ) . toBeDefined ( ) ;
2523 } ) ;
26-
27- // TODO - Nivo not rendering internal chart
28- it . skip ( 'sets left and bottom axis attributes each to null by default to prevent unwanted tick marks along the axes' , async ( ) => {
29- // let component = renderer.create();
30- // let instance = null;
31- // await renderer.act(async () => {
32- // component = await renderer.create(<BarGraph graphData={staggeredData} graphIndex="year" valueKeys={['value']} />);
33- // instance = component.root;
34- // });
35- //
36- // const barGraphCanvas = instance.findByType(ResponsiveBar);
37- // expect(barGraphCanvas.props.axisLeft).toBeNull();
38- // expect(barGraphCanvas.props.axisBottom).toBeNull();
39- } ) ;
4024} ) ;
4125
4226describe ( 'BarGraph component - Custom bar graph' , ( ) => {
4327 window . ResizeObserver = ResizeObserver ;
44- const barGraph = < BarGraph graphData = { staggeredData } graphIndex = "year" valueKeys = { [ 'value' ] } useCustomBarComponent /> ;
28+ const mouseEnterPropSpy = jest . fn ( ) ;
29+
30+ const barGraph = (
31+ < BarGraph
32+ graphData = { staggeredData }
33+ graphIndex = "year"
34+ valueKeys = { [ 'value' ] }
35+ useCustomBarComponent
36+ mouseEnter = { mouseEnterPropSpy }
37+ />
38+ ) ;
4539 const mouseEnterSpy = jest . spyOn ( helpers , 'mouseEnterEvent' ) ;
4640 const mouseLeaveSpy = jest . spyOn ( helpers , 'mouseLeaveEvent' ) ;
4741
48- // TODO - Nivo not rendering internal chart
49- it . skip ( 'creates a customBarGraph' , ( ) => {
50- // let component = renderer.create();
51- // renderer.act(() => {
52- // component = renderer.create(barGraph);
53- // });
54- // const instance = component.root;
55- // const responsiveBar = instance.findByType(ResponsiveBar);
56- // expect(responsiveBar.props.barComponent).toBeDefined();
57- } ) ;
58-
5942 it ( 'triggers mouseEnter and mouseLeave events' , ( ) => {
6043 jest . clearAllMocks ( ) ;
6144 const { getByTestId } = render ( barGraph ) ;
6245 const container = getByTestId ( 'barGraph' ) ;
6346 fireEvent . mouseEnter ( container ) ;
6447 expect ( mouseEnterSpy ) . toHaveBeenCalledTimes ( 1 ) ;
65-
48+ expect ( mouseEnterPropSpy ) . toHaveBeenCalled ( ) ;
6649 fireEvent . mouseLeave ( container ) ;
6750 expect ( mouseLeaveSpy ) . toHaveBeenCalledTimes ( 1 ) ;
6851 } ) ;
0 commit comments