-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathindex.spec.js
More file actions
42 lines (37 loc) · 1.44 KB
/
index.spec.js
File metadata and controls
42 lines (37 loc) · 1.44 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
import { expectConsoleCallsDev } from '../../../helpers/utils.js';
export default {
props: {
isFalse: false,
isUndefined: undefined,
isNull: null,
isTrue: true,
isEmptyString: '',
isZero: 0,
isNaN: NaN,
},
clientProps: {
isFalse: 'false',
isUndefined: 'undefined', // mismatch. should be literally `null`, not the string `"undefined"`
isNull: 'null', // mismatch. should be literally `null`, not the string `"null"`
isTrue: 'true',
isEmptyString: '',
isZero: '0',
isNaN: 'NaN',
},
test(target, snapshots, consoleCalls) {
const divs = target.shadowRoot.querySelectorAll('div');
const expectedAttrValues = ['false', 'undefined', 'null', 'true', '', '0', 'NaN'];
expect(divs).toHaveSize(expectedAttrValues.length);
for (let i = 0; i < expectedAttrValues.length; i++) {
expect(divs[i].getAttribute('data-foo')).toEqual(expectedAttrValues[i]);
}
expectConsoleCallsDev(consoleCalls, {
error: [],
warn: [
'Hydration attribute mismatch on: <div> - rendered on server: data-foo=null - expected on client: data-foo="undefined"',
'Hydration attribute mismatch on: <div> - rendered on server: data-foo=null - expected on client: data-foo="null"',
'Hydration completed with errors.',
],
});
},
};