2023-01-14 03:15:43 +01:00
|
|
|
import { test, expect } from '@playwright/experimental-ct-react';
|
|
|
|
import Button from '@/components/Button';
|
|
|
|
import EmptyFragment from '@/components/EmptyFragment';
|
|
|
|
|
|
|
|
test('render props', async ({ mount }) => {
|
|
|
|
const component = await mount(<Button title="Submit" />);
|
|
|
|
await expect(component).toContainText('Submit');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('render attributes', async ({ mount }) => {
|
|
|
|
const component = await mount(<Button className="primary" title="Submit" />);
|
|
|
|
await expect(component).toHaveClass('primary');
|
|
|
|
});
|
|
|
|
|
2023-11-28 00:53:50 +01:00
|
|
|
test('render an empty component', async ({ mount, page }) => {
|
2023-01-14 03:15:43 +01:00
|
|
|
const component = await mount(<EmptyFragment />);
|
2023-11-28 00:53:50 +01:00
|
|
|
expect(await page.evaluate(() => 'props' in window && window.props)).toEqual({});
|
2023-01-14 03:15:43 +01:00
|
|
|
expect(await component.allTextContents()).toEqual(['']);
|
|
|
|
expect(await component.textContent()).toBe('');
|
|
|
|
await expect(component).toHaveText('');
|
|
|
|
});
|