playwright/tests/components/ct-vue2-cli/tests/slots/slots.spec.ts
2023-01-12 10:46:15 -08:00

36 lines
1 KiB
TypeScript

import { test, expect } from '@playwright/experimental-ct-vue2';
import DefaultSlot from '@/components/DefaultSlot.vue';
import NamedSlots from '@/components/NamedSlots.vue';
test('render a default slot', async ({ mount }) => {
const component = await mount(DefaultSlot, {
slots: {
default: 'Main Content',
},
});
await expect(component).toContainText('Main Content');
});
test('render a component with multiple slots', async ({ mount }) => {
const component = await mount(DefaultSlot, {
slots: {
default: ['one', 'two'],
},
});
await expect(component).toContainText('one');
await expect(component).toContainText('two');
});
test('render a component with a named slot', async ({ mount }) => {
const component = await mount(NamedSlots, {
slots: {
header: 'Header',
main: 'Main Content',
footer: 'Footer',
},
});
await expect(component).toContainText('Header');
await expect(component).toContainText('Main Content');
await expect(component).toContainText('Footer');
});