-
-
Notifications
You must be signed in to change notification settings - Fork 835
Expand file tree
/
Copy pathshadow-dom-basic.test.tsx
More file actions
38 lines (28 loc) · 1.22 KB
/
shadow-dom-basic.test.tsx
File metadata and controls
38 lines (28 loc) · 1.22 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
import { h } from '@stencil/core';
import { render } from '@wdio/browser-runner/stencil';
describe('shadow-dom-basic', () => {
beforeEach(() => {
render({
template: () => <shadow-dom-basic-root></shadow-dom-basic-root>,
});
});
it('render', async () => {
await $('shadow-dom-basic-root').waitForExist();
// Firefox fails without this
await browser.pause();
const elm = document.querySelector('shadow-dom-basic-root');
expect(elm.shadowRoot).toBeDefined();
const shadowDomBasic = elm.shadowRoot.lastElementChild;
const lightDiv = elm.shadowRoot.lastElementChild.children[0];
expect(lightDiv.nodeName).toBe('DIV');
expect(lightDiv.textContent.trim()).toBe('light');
expect(shadowDomBasic.nodeName).toBe('SHADOW-DOM-BASIC');
const shadowDiv = shadowDomBasic.shadowRoot.lastElementChild.previousElementSibling;
expect(shadowDiv.nodeName).toBe('DIV');
expect(shadowDiv.textContent.trim()).toBe('shadow');
const shadowBG = window.getComputedStyle(shadowDiv).backgroundColor;
expect(shadowBG).toBe('rgb(0, 0, 0)');
const lightBG = window.getComputedStyle(shadowDomBasic.lastElementChild).backgroundColor;
expect(lightBG).toBe('rgb(255, 255, 0)');
});
});