-
Notifications
You must be signed in to change notification settings - Fork 6
/
switch.test.js
57 lines (50 loc) 路 1.47 KB
/
switch.test.js
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
52
53
54
55
56
57
import '../vwc-switch.js';
import {
waitNextTask,
textToDomToParent,
assertComputedStyle,
} from '../../../test/test-helpers.js';
import { chaiDomDiff } from '@open-wc/semantic-dom-diff';
chai.use(chaiDomDiff);
const VWC_SWITCH = 'vwc-switch';
describe('switch', () => {
let addedElements = [];
afterEach(() => {
addedElements.forEach(elm => elm.remove());
});
it('should have vwc-switch defined', async () => {
assert.exists(
customElements.get(VWC_SWITCH, 'vwc-switch element is not defined')
);
});
it('should have internal contents', async () => {
addedElements = textToDomToParent(`<${VWC_SWITCH}></${VWC_SWITCH}>`);
const actualElement = addedElements[0];
await waitNextTask();
expect(actualElement.shadowRoot.innerHTML).to.equalSnapshot();
});
describe('sizing', () => {
it('should have normal size by default', async () => {
addedElements = textToDomToParent(`<${VWC_SWITCH}></${VWC_SWITCH}>`);
const actualElement = addedElements[0];
await waitNextTask();
const expectedStyles = {
width: '36px',
height: '20px',
};
assertComputedStyle(actualElement, expectedStyles);
});
it('should have enlarged size when enlarged', async () => {
addedElements = textToDomToParent(
`<${VWC_SWITCH} enlarged></${VWC_SWITCH}>`
);
const actualElement = addedElements[0];
await waitNextTask();
const expectedStyles = {
width: '60px',
height: '32px',
};
assertComputedStyle(actualElement, expectedStyles);
});
});
});