import { create } from 'react-test-renderer'; import Flex from './Flex'; import TileData from './TileData'; describe('TileData', () => { it('renders', () => { const tree = create( {}} selected title="Text Impressions" value="1.23M" />, ).toJSON(); expect(tree).toMatchSnapshot(); }); test('TileData renders with tooltip', () => { const component = create( {}} selected title="Text Impressions" tooltip={{ text: 'This is a tooltip' }} value="1.23M" />, ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); test('TileData renders all colors as expected', () => { const colors = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; const component = create( {colors.map((color: any) => ( {}} selected title="Text Impressions" tooltip={{ text: 'This is a tooltip' }} value="1.23M" /> ))} , ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); test('Tiledata is disabled', () => { const component = create( {}} selected showCheckbox title="Text Impressions" tooltip={{ text: 'This is a tooltip' }} value="1.23M" />, ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); test('TileData title truncates when really long', () => { const component = create( {}} selected title="This is some super super super long text and you shouldn't be able to read the last part of it. It's going to use ellipsis to cutoff the last part" tooltip={{ text: 'This is a tooltip' }} value="1.23M" />, ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); test('TileData shows readonly checkboxes', () => { const component = create( {}} selected showCheckbox title="" tooltip={{ text: 'This is a tooltip' }} value="1.43M" /> {}} selected showCheckbox title="" tooltip={{ text: 'This is a tooltip' }} value="1.13M" /> {}} selected showCheckbox title="" tooltip={{ text: 'This is a tooltip' }} value="1.13M" /> , ); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); });