import { GEL } from '@westpac/core'; import { render } from '@testing-library/react'; import wbc from '@westpac/wbc'; import { overridesTest } from '../../../../helpers/tests/overrides-test.js'; import { nestingTest } from '../../../../helpers/tests/nesting-test.js'; import * as pictograms from '@westpac/pictogram'; import { Pictogram, PictogramProps } from '../../src/Pictogram.tsx'; overridesTest({ name: 'pictogram', overrides: ['Pictogram'], Component: (props: any) => , }); nestingTest({ name: 'pictogram', Component: (props: any) => , }); function SimplePictogram(props: PictogramProps) { return ( ); } describe('Pictogram components', () => { test('should render base Pictogram component', () => { const { container } = render(); expect(container).toBeInTheDocument(); }); // Tests every Pictogram in the library to see if it renders correctly for (let [key, val] of Object.entries(pictograms)) { // need to create new variable with expected typing and check if val is function for TS let typedVal: Function; if (typeof val === 'function') { typedVal = val; } test(`should render ${key} with testing prop options`, () => { const TestPictogram = (props: PictogramProps) => { return typedVal({ ...props }); }; const DefaultTestPictogram = () => { return typedVal({} as PictogramProps); }; const { container } = render( ); expect(container).toBeInTheDocument(); }); } test('should render Pictogram with correct height and width when width passed in', () => { const { getByTestId } = render( ); const testPicto = getByTestId('test-pictogram'); expect(testPicto).toHaveStyle('width: 100px'); expect(testPicto).toHaveStyle('height: 100px'); }); });