forked from sand4rt/playwright-ct-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.spec.ts
51 lines (42 loc) · 1.49 KB
/
update.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { test, expect } from '@sand4rt/experimental-ct-web';
import { Counter } from '@/components/Counter';
test('update props without remounting', async ({ mount }) => {
const component = await mount(Counter, {
props: { count: 9001 },
});
await expect(component.locator('#props')).toContainText('9001');
await component.update({
props: { count: 1337 },
});
await expect(component).not.toContainText('9001');
await expect(component.locator('#props')).toContainText('1337');
await expect(component.locator('#remount-count')).toContainText('1');
});
test('update event listeners without remounting', async ({ mount }) => {
const messages: string[] = [];
const component = await mount(Counter, {
on: {
submit: (data: string) => messages.push(data),
},
});
await component.update({
on: {
submit: (data: string) => messages.push(data),
},
});
await component.click();
expect(messages).toEqual(['hello']);
await expect(component.locator('#remount-count')).toContainText('1');
});
test('update slots without remounting', async ({ mount }) => {
const component = await mount(Counter, {
slots: { default: 'Default Slot' },
});
await expect(component).toContainText('Default Slot');
await component.update({
slots: { main: '<div>Test Slot<div>' },
});
await expect(component).toContainText('Default Slot');
await expect(component).toContainText('Test Slot');
await expect(component.locator('#remount-count')).toContainText('1');
});