import { expect } from 'chai'; import { createRenderer, isJsdom } from '@mui/internal-test-utils'; import { ThemeProvider } from 'styled-components'; import styled from '..'; import GlobalStyles from './GlobalStyles'; describe('GlobalStyles', () => { const { render } = createRenderer(); it.skipIf(isJsdom())('should add global styles', function test() { const { container } = render(
Blue text
, ); expect(container.getElementsByTagName('span')[0]).toHaveComputedStyle({ color: 'rgb(0, 0, 255)', }); }); it.skipIf(isJsdom())('should add global styles using JS syntax', function test() { const { container } = render(
Blue text
, ); expect(container.getElementsByTagName('span')[0]).toHaveComputedStyle({ color: 'rgb(0, 0, 255)', }); }); it.skipIf(isJsdom())('should add global styles using function', function test() { const { container } = render( ({ span: { color: theme.color } })} /> Blue text , ); expect(container.getElementsByTagName('span')[0]).toHaveComputedStyle({ color: 'rgb(0, 0, 255)', }); }); it('should not throw if no theme is available', () => { expect(() => render( ({ span: { color: theme.color } })} />, ), ).not.to.throw(); }); it.skipIf(isJsdom())('should give precedence to styled()', function test() { const Span = styled('span')` color: rgb(255, 0, 0); `; const { container } = render(
Red text
, ); expect(container.getElementsByTagName('span')[0]).toHaveComputedStyle({ color: 'rgb(255, 0, 0)', }); }); it.skipIf(isJsdom())('should give precedence to styled() using JS syntax', function test() { const Span = styled('span')({ color: 'rgb(255, 0, 0)', }); const { container } = render(
Red text
, ); expect(container.getElementsByTagName('span')[0]).toHaveComputedStyle({ color: 'rgb(255, 0, 0)', }); }); });