-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathindex.spec.js
More file actions
63 lines (51 loc) · 1.98 KB
/
index.spec.js
File metadata and controls
63 lines (51 loc) · 1.98 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
59
60
61
62
63
import { createElement } from 'lwc';
import Any from 'x/any';
import Reset from 'x/reset';
import None from 'x/none';
import NativeOnly from 'x/native';
import { jasmine } from '../../../helpers/jasmine.js';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
} from '../../../helpers/reporting-control.js';
/**
* These tests must be the first ones to generate the component def for the components they use.
* This is because subsequent calls to create the component will use the cached ctor rather than
* recreating the entire def. We only report on that initial def creation for perf reasons.
*/
describe('shadow support mode reporting', () => {
let dispatcher;
beforeEach(() => {
dispatcher = jasmine.createSpy();
attachReportingControlDispatcher(dispatcher, ['ShadowSupportModeUsage']);
});
afterEach(() => {
detachReportingControlDispatcher();
});
it('should report use of value "any"', () => {
expect(() => {
createElement('x-any', { is: Any });
}).toLogWarningDev(/Invalid value 'any' for static property shadowSupportMode/);
expect(dispatcher).toHaveBeenCalledTimes(1);
expect(dispatcher).toHaveBeenCalledWith('ShadowSupportModeUsage', {
tagName: Any.name,
mode: 'any',
});
});
it('should report use of value "native"', () => {
createElement('x-native', { is: NativeOnly });
expect(dispatcher).toHaveBeenCalledTimes(1);
expect(dispatcher).toHaveBeenCalledWith('ShadowSupportModeUsage', {
tagName: NativeOnly.name,
mode: 'native',
});
});
it('should not report use of value "reset"', () => {
createElement('x-reset', { is: Reset });
expect(dispatcher).toHaveBeenCalledTimes(0);
});
it('should not report when no value is provided', () => {
createElement('x-none', { is: None });
expect(dispatcher).toHaveBeenCalledTimes(0);
});
});