UNPKG

@axeptio/design-system

Version:
41 lines (36 loc) 1.7 kB
import React from 'react'; import { test, expect } from '@playwright/experimental-ct-react'; import Label from './index.jsx'; import { axeptio } from '../../../Presets'; import { Provider } from '../../../DesignSystem'; /** * Custom test utility function that wraps a test component with ThemeProvider * This function cannot be imported from another file because it breaks the tests * https://github.com/microsoft/playwright/issues/15620 * @param {JSX.Element} component */ function withThemeProvider(component) { return ( /* @ts-expect-error Server Component */ <Provider theme={axeptio}>{component}</Provider> ); } test.use({ viewport: { width: 500, height: 500 } }); test('Default Label', async ({ mount }) => { const component = await mount(withThemeProvider(<Label>Label</Label>)); await expect(component).toHaveCSS('display', 'inline-block'); await expect(component).toHaveCSS('margin-bottom', '4px'); await expect(component).toHaveCSS('font-size', '16px'); await expect(component).toHaveCSS('font-weight', '700'); await expect(component).toHaveCSS('color', 'rgb(138, 142, 148)'); await expect(component).toHaveCSS('text-transform', 'uppercase'); }); test('Large Label', async ({ mount }) => { const component = await mount(withThemeProvider(<Label large>Label</Label>)); await expect(component).toHaveCSS('display', 'inline-block'); await expect(component).toHaveCSS('margin-bottom', '4px'); await expect(component).toHaveCSS('font-size', '18px'); await expect(component).toHaveCSS('font-weight', '700'); await expect(component).toHaveCSS('color', 'rgb(138, 142, 148)'); await expect(component).toHaveCSS('text-transform', 'uppercase'); });