Download wp-calypso/client/components/d3-base/test/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/d3-base/test/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/d3-base/test/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/d3-base/test/index.js
1.42 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { render } from '@testing-library/react'; | |
| import D3Base from '..'; | |
| const noop = () => {}; | |
| describe( 'D3base', () => { | |
| test( 'should have d3-base CSS class', () => { | |
| const { container } = render( <D3Base drawChart={ noop } getParams={ noop } /> ); | |
| expect( container.firstChild ).toHaveClass( 'd3-base' ); | |
| } ); | |
| test( 'should render an svg', () => { | |
| const getParams = () => ( { width: 100, height: 100 } ); | |
| const { container } = render( <D3Base drawChart={ noop } getParams={ getParams } /> ); | |
| expect( container.getElementsByTagName( 'svg' ) ).toHaveLength( 1 ); | |
| } ); | |
| test( 'should render a result of the drawChart prop', () => { | |
| const drawChart = ( svg ) => { | |
| return svg.append( 'circle' ); | |
| }; | |
| const getParams = () => ( { | |
| width: 100, | |
| height: 100, | |
| } ); | |
| const { container } = render( <D3Base drawChart={ drawChart } getParams={ getParams } /> ); | |
| expect( container.getElementsByTagName( 'circle' ) ).toHaveLength( 1 ); | |
| } ); | |
| test( 'should pass a property of getParams output to drawChart function', () => { | |
| const drawChart = ( svg, params ) => { | |
| return svg.append( params.tagName ); | |
| }; | |
| const getParams = () => ( { | |
| tagName: 'circle', | |
| } ); | |
| const { container } = render( <D3Base drawChart={ drawChart } getParams={ getParams } /> ); | |
| expect( container.getElementsByTagName( 'circle' ) ).toHaveLength( 1 ); | |
| } ); | |
| } ); | |