@axeptio/design-system
Version:
Design System for Axeptio
51 lines (43 loc) • 1.6 kB
JSX
// @ts-check
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react';
import Select from './index.jsx';
import data from './data.json';
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 } });
const args = {
value: [],
optionsMessage: 'No option here',
multi: true,
options: data,
onChange: undefined
};
test('Fonts Select', async ({ mount }) => {
const component = await mount(withThemeProvider(<Select {...args} />));
await expect(component).toHaveCSS('font-family', '"Source Sans Pro", sans-serif');
});
test('Color Select', async ({ mount }) => {
const component = await mount(withThemeProvider(<Select {...args} />));
await expect(component).toHaveCSS('color', 'rgb(0, 0, 0)');
});
test('Size Fonts Select', async ({ mount }) => {
const component = await mount(withThemeProvider(<Select {...args} />));
await expect(component).toHaveCSS('font-size', '16px');
});
test('Select enabled', async ({ mount }) => {
const component = await mount(withThemeProvider(<Select {...args} />));
await expect(component).toBeEnabled();
});