-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathindex.spec.js
More file actions
58 lines (52 loc) · 1.9 KB
/
index.spec.js
File metadata and controls
58 lines (52 loc) · 1.9 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
47
48
49
50
51
52
53
54
55
56
57
58
import { createElement } from 'lwc';
import Shadow from 'x/shadow';
import Light from 'x/light';
import { jasmine } from '../../../helpers/jasmine.js';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
} from '../../../helpers/reporting-control.js';
describe('lwc:render-mode', () => {
let dispatcher;
beforeEach(() => {
dispatcher = jasmine.createSpy();
attachReportingControlDispatcher(dispatcher, ['RenderModeMismatch']);
});
afterEach(() => {
detachReportingControlDispatcher();
});
it('should throw error if shadow template is passed to light component', () => {
expect(() => {
const root = createElement('x-test', { is: Light });
document.body.appendChild(root);
}).toLogErrorDev(
/Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of <x-test>./
);
expect(dispatcher.calls.allArgs()).toEqual([
[
'RenderModeMismatch',
{
tagName: 'x-test',
mode: 0, // RenderMode.Light
},
],
]);
});
it('should throw error if light template is passed to shadow component', () => {
expect(() => {
const root = createElement('x-test', { is: Shadow });
document.body.appendChild(root);
}).toLogErrorDev(
/Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from <x-test> or set it to 'lwc:render-mode="shadow"/
);
expect(dispatcher.calls.allArgs()).toEqual([
[
'RenderModeMismatch',
{
tagName: 'x-test',
mode: 1, // RenderMode.Shadow
},
],
]);
});
});