-
-
Notifications
You must be signed in to change notification settings - Fork 833
Expand file tree
/
Copy pathcmp.test.tsx
More file actions
46 lines (38 loc) · 1.7 KB
/
cmp.test.tsx
File metadata and controls
46 lines (38 loc) · 1.7 KB
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
import { h } from '@stencil/core';
import { render } from '@wdio/browser-runner/stencil';
import { $, expect } from '@wdio/globals';
// Verify attr: prefix in JSX correctly passes values as attributes to nested component
describe('prefix-attr', () => {
before(async () => {
render({
components: [],
template: () => <prefix-attr-root></prefix-attr-root>,
});
});
it('should pass values from parent to nested component using attr: prefix', async () => {
const nested = await $('prefix-attr-nested');
await expect(nested).toHaveAttribute('message', 'Hello');
await expect(nested).toHaveAttribute('count', '42');
await expect(nested).toHaveAttribute('enabled');
await expect(nested).toHaveAttribute('null-value', 'not-null');
await expect(nested).toHaveAttribute('undefined-value', 'defined');
});
it('should update nested component when parent state changes', async () => {
const nested = await $('prefix-attr-nested');
const updateBtn = await $('button=Update Message');
await updateBtn.click();
await expect(nested).toHaveAttribute('message', 'Updated');
const countBtn = await $('button=Update Count');
await countBtn.click();
await expect(nested).toHaveAttribute('count', '99');
const disableBtn = await $('button=Disable');
await disableBtn.click();
await expect(nested).not.toHaveAttribute('enabled');
const setNullBtn = await $('button=Set Null to String');
await setNullBtn.click();
await expect(nested).not.toHaveAttribute('null-value');
const setUndefinedBtn = await $('button=Set Undefined to String');
await setUndefinedBtn.click();
await expect(nested).not.toHaveAttribute('undefined-value');
});
});