-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathindex.spec.js
More file actions
46 lines (39 loc) · 1.79 KB
/
index.spec.js
File metadata and controls
46 lines (39 loc) · 1.79 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 { createElement } from 'lwc';
import Component from 'x/component';
afterEach(() => {
window.__lwcResetGlobalStylesheets();
});
describe('important styling and style override', () => {
it('should render !important styles correctly', async () => {
const elm = createElement('x-component', { is: Component });
document.body.appendChild(elm);
await Promise.resolve();
const importantDivs = elm.shadowRoot.querySelectorAll('.important');
expect(importantDivs.length).toBeGreaterThan(0);
for (const div of importantDivs) {
expect(getComputedStyle(div).getPropertyValue('color')).toBe('rgb(255, 0, 0)');
expect(div.style.getPropertyPriority('color')).toBe('important');
}
});
it('should render inline styles correctly', async () => {
const elm = createElement('x-component', { is: Component });
document.body.appendChild(elm);
await Promise.resolve();
const inlineDivs = elm.shadowRoot.querySelectorAll('.inline');
expect(inlineDivs.length).toBeGreaterThan(0);
for (const div of inlineDivs) {
expect(getComputedStyle(div).getPropertyValue('color')).toBe('rgb(255, 0, 0)');
expect(div.style.getPropertyPriority('color')).not.toBe('important');
}
});
it('should render untouched styles correctly', async () => {
const elm = createElement('x-component', { is: Component });
document.body.appendChild(elm);
await Promise.resolve();
const untouchedDivs = elm.shadowRoot.querySelectorAll('.untouched');
expect(untouchedDivs.length).toBeGreaterThan(0);
for (const div of untouchedDivs) {
expect(getComputedStyle(div).getPropertyValue('color')).toBe('rgb(0, 0, 255)');
}
});
});