import React from 'react'; import { render } from '@testing-library/react'; import { axe } from 'jest-axe'; import 'jest-styled-components'; import 'regenerator-runtime/runtime'; import 'jest-axe/extend-expect'; import { Node } from 'grommet-icons'; import { Grommet } from '../../Grommet'; import { Spinner } from '..'; import { ThemeType } from '../../..'; describe('Spinner', () => { test('should have no accessibility violations', async () => { const { container } = render( , ); const results = await axe(container); expect(results).toHaveNoViolations(); expect(container.firstChild).toMatchSnapshot(); }); test('size renders', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('size renders', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('round renders', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('border renders', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('spinner changes according to theme', () => { const theme: ThemeType = { spinner: { size: { small: '30px' }, container: { animation: { type: 'rotateLeft', duration: 900 }, border: false, background: 'red', pad: 'large', round: 'medium', }, }, }; const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('spinner icon changes according to theme', () => { const theme = { spinner: { icon: Node, container: { color: 'accent-2', align: 'center', justify: 'center', size: 'large', animation: { type: 'rotateLeft', duration: 900 }, }, }, }; const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); test('spinner color renders over theme settings', () => { const theme: ThemeType = { spinner: { container: { border: [ { side: 'all', color: 'background-contrast', size: 'medium' }, { side: 'right', color: 'green', size: 'medium' }, { side: 'top', color: 'green', size: 'medium' }, { side: 'left', color: 'green', size: 'medium' }, ], }, }, }; const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); });