@markuplint/types 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/check.spec.js +63 -58
- package/lib/css-syntax.spec.js +151 -149
- package/lib/list.spec.js +117 -117
- package/lib/primitive/index.spec.js +52 -52
- package/lib/rfc/is-bcp-47.spec.js +8 -8
- package/lib/token/token-collection.spec.js +155 -134
- package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
- package/lib/whatwg/check-autocomplete.spec.js +360 -360
- package/lib/whatwg/check-datetime/index.spec.js +277 -276
- package/lib/whatwg/check-mime-type.spec.js +52 -52
- package/lib/whatwg/is-abs-url.spec.js +5 -5
- package/lib/whatwg/is-itemprop-name.js +1 -1
- package/package.json +8 -10
- package/test/check.spec.js +89 -0
- package/test/css-syntax.spec.js +165 -0
- package/test/list.spec.js +133 -0
- package/test/primitive/index.spec.js +65 -0
- package/test/rfc/is-bcp-47.spec.js +23 -0
- package/test/token/token-collection.spec.js +146 -0
- package/test/w3c/check-serialized-permissions-policy.spec.js +36 -0
- package/test/whatwg/check-autocomplete.spec.js +387 -0
- package/test/whatwg/check-datetime/index.spec.js +336 -0
- package/test/whatwg/check-mime-type.spec.js +59 -0
- package/test/whatwg/is-abs-url.spec.js +8 -0
package/lib/list.spec.js
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
const list_1 = require(
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
const list_1 = require('./list');
|
|
5
5
|
test('Zero space', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
const type = { token: 'Zero', separator: 'space' };
|
|
7
|
+
expect((0, list_1.checkList)('0', type).matched).toBe(true);
|
|
8
|
+
expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
|
|
9
|
+
expect((0, list_1.checkList)(' 0 0', type).matched).toBe(true);
|
|
10
|
+
expect((0, list_1.checkList)(' 0 0 ', type).matched).toBe(true);
|
|
11
|
+
expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(true);
|
|
12
|
+
expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
|
|
13
|
+
expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
|
|
14
|
+
expect((0, list_1.checkList)('1', type).matched).toBe(false);
|
|
15
|
+
expect((0, list_1.checkList)(' 1 ', type).matched).toBe(false);
|
|
16
|
+
expect((0, list_1.checkList)(' 1 0', type).matched).toBe(false);
|
|
17
|
+
expect((0, list_1.checkList)(' 1 0 ', type).matched).toBe(false);
|
|
18
|
+
expect((0, list_1.checkList)('0 1 0 ', type).matched).toBe(false);
|
|
19
|
+
expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
|
|
20
|
+
expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
|
|
21
21
|
});
|
|
22
22
|
test('Zero comma', () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
const type = { token: 'Zero', separator: 'comma' };
|
|
24
|
+
expect((0, list_1.checkList)('0', type).matched).toBe(true);
|
|
25
|
+
expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
|
|
26
|
+
expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
|
|
27
|
+
expect((0, list_1.checkList)(' 0,0', type).matched).toBe(true);
|
|
28
|
+
expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
|
|
29
|
+
expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
|
|
30
|
+
expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(true);
|
|
31
|
+
expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(true);
|
|
32
|
+
expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
|
|
33
|
+
expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
|
|
34
34
|
});
|
|
35
35
|
test('Zero comma (disallowToSurroundBySpaces)', () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
const type = { token: 'Zero', separator: 'comma', disallowToSurroundBySpaces: true };
|
|
37
|
+
expect((0, list_1.checkList)('0', type).matched).toBe(true);
|
|
38
|
+
expect((0, list_1.checkList)(' 0 ', type).matched).toBe(false);
|
|
39
|
+
expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
|
|
40
|
+
expect((0, list_1.checkList)(' 0,0', type).matched).toBe(false);
|
|
41
|
+
expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
|
|
42
|
+
expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
|
|
43
|
+
expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(false);
|
|
44
|
+
expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(false);
|
|
45
|
+
expect((0, list_1.checkList)('0,0,0,0', type).matched).toBe(true);
|
|
46
|
+
expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
|
|
47
|
+
expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
|
|
48
48
|
});
|
|
49
49
|
test('Location of the token', () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
50
|
+
const type = { token: 'Accept', separator: 'comma' };
|
|
51
|
+
expect((0, list_1.checkList)('x/y;a=b', type)).toStrictEqual({
|
|
52
|
+
candidate: 'x/y',
|
|
53
|
+
column: 4,
|
|
54
|
+
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
55
|
+
length: 4,
|
|
56
|
+
line: 1,
|
|
57
|
+
matched: false,
|
|
58
|
+
offset: 3,
|
|
59
|
+
raw: ';a=b',
|
|
60
|
+
reason: 'extra-token',
|
|
61
|
+
partName: 'the content of the list',
|
|
62
|
+
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
63
|
+
});
|
|
64
|
+
expect((0, list_1.checkList)('x/y,x/y;a=b', type)).toStrictEqual({
|
|
65
|
+
candidate: 'x/y',
|
|
66
|
+
column: 8,
|
|
67
|
+
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
68
|
+
length: 4,
|
|
69
|
+
line: 1,
|
|
70
|
+
matched: false,
|
|
71
|
+
offset: 7,
|
|
72
|
+
raw: ';a=b',
|
|
73
|
+
reason: 'extra-token',
|
|
74
|
+
partName: 'the content of the list',
|
|
75
|
+
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
76
|
+
});
|
|
77
|
+
expect((0, list_1.checkList)('x/y\n,\nx/y;a=b', type)).toStrictEqual({
|
|
78
|
+
candidate: 'x/y',
|
|
79
|
+
column: 4,
|
|
80
|
+
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
81
|
+
length: 4,
|
|
82
|
+
line: 3,
|
|
83
|
+
matched: false,
|
|
84
|
+
offset: 9,
|
|
85
|
+
raw: ';a=b',
|
|
86
|
+
reason: 'extra-token',
|
|
87
|
+
partName: 'the content of the list',
|
|
88
|
+
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
89
|
+
});
|
|
90
90
|
});
|
|
91
91
|
test('Expected comma', () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
92
|
+
const type = { token: 'Accept', separator: 'comma' };
|
|
93
|
+
expect((0, list_1.checkList)('x/y,', type)).toStrictEqual({
|
|
94
|
+
column: 4,
|
|
95
|
+
expects: undefined,
|
|
96
|
+
length: 1,
|
|
97
|
+
line: 1,
|
|
98
|
+
matched: false,
|
|
99
|
+
offset: 3,
|
|
100
|
+
raw: ',',
|
|
101
|
+
reason: 'extra-token',
|
|
102
|
+
ref: null,
|
|
103
|
+
});
|
|
104
|
+
expect((0, list_1.checkList)('x/y,,x/y', type)).toStrictEqual({
|
|
105
|
+
column: 5,
|
|
106
|
+
expects: undefined,
|
|
107
|
+
length: 1,
|
|
108
|
+
line: 1,
|
|
109
|
+
matched: false,
|
|
110
|
+
offset: 4,
|
|
111
|
+
raw: ',',
|
|
112
|
+
reason: 'unexpected-comma',
|
|
113
|
+
ref: null,
|
|
114
|
+
});
|
|
115
115
|
});
|
|
116
116
|
test('Missing comma', () => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
const type = { token: 'Accept', separator: 'comma' };
|
|
118
|
+
expect((0, list_1.checkList)('a/b,x/y a/z', type)).toStrictEqual({
|
|
119
|
+
column: 9,
|
|
120
|
+
candidate: ',a/z',
|
|
121
|
+
expects: undefined,
|
|
122
|
+
length: 3,
|
|
123
|
+
line: 1,
|
|
124
|
+
matched: false,
|
|
125
|
+
offset: 8,
|
|
126
|
+
raw: 'a/z',
|
|
127
|
+
reason: 'missing-comma',
|
|
128
|
+
ref: null,
|
|
129
|
+
});
|
|
130
130
|
});
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
const _1 = require(
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
const _1 = require('.');
|
|
5
5
|
test('int', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
expect((0, _1.isInt)('0')).toBe(true);
|
|
7
|
+
expect((0, _1.isInt)('1')).toBe(true);
|
|
8
|
+
expect((0, _1.isInt)('-0')).toBe(true);
|
|
9
|
+
expect((0, _1.isInt)('-1')).toBe(true);
|
|
10
|
+
expect((0, _1.isInt)('10')).toBe(true);
|
|
11
|
+
expect((0, _1.isInt)('100')).toBe(true);
|
|
12
|
+
expect((0, _1.isInt)('1.00')).toBe(false);
|
|
13
|
+
expect((0, _1.isInt)('.001')).toBe(false);
|
|
14
|
+
expect((0, _1.isInt)(' 1 ')).toBe(false);
|
|
15
|
+
expect((0, _1.isInt)('- 1')).toBe(false);
|
|
16
16
|
});
|
|
17
17
|
test('uint', () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
expect((0, _1.isUint)('0')).toBe(true);
|
|
19
|
+
expect((0, _1.isUint)('1')).toBe(true);
|
|
20
|
+
expect((0, _1.isUint)('10')).toBe(true);
|
|
21
|
+
expect((0, _1.isUint)('100')).toBe(true);
|
|
22
|
+
expect((0, _1.isUint)('-0')).toBe(false);
|
|
23
|
+
expect((0, _1.isUint)('-1')).toBe(false);
|
|
24
|
+
expect((0, _1.isUint)('1.00')).toBe(false);
|
|
25
|
+
expect((0, _1.isUint)('.001')).toBe(false);
|
|
26
|
+
expect((0, _1.isUint)(' 1 ')).toBe(false);
|
|
27
|
+
expect((0, _1.isUint)('- 1')).toBe(false);
|
|
28
28
|
});
|
|
29
29
|
test('float', () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
expect((0, _1.isFloat)('0')).toBe(true);
|
|
31
|
+
expect((0, _1.isFloat)('1')).toBe(true);
|
|
32
|
+
expect((0, _1.isFloat)('10')).toBe(true);
|
|
33
|
+
expect((0, _1.isFloat)('100')).toBe(true);
|
|
34
|
+
expect((0, _1.isFloat)('-0')).toBe(true);
|
|
35
|
+
expect((0, _1.isFloat)('-1')).toBe(true);
|
|
36
|
+
expect((0, _1.isFloat)('1.00')).toBe(true);
|
|
37
|
+
expect((0, _1.isFloat)('.001')).toBe(true);
|
|
38
|
+
expect((0, _1.isFloat)(' 1 ')).toBe(false);
|
|
39
|
+
expect((0, _1.isFloat)('- 1')).toBe(false);
|
|
40
40
|
});
|
|
41
41
|
test('nonZeroUint', () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
expect((0, _1.isNonZeroUint)('0')).toBe(false);
|
|
43
|
+
expect((0, _1.isNonZeroUint)('1')).toBe(true);
|
|
44
|
+
expect((0, _1.isNonZeroUint)('10')).toBe(true);
|
|
45
|
+
expect((0, _1.isNonZeroUint)('100')).toBe(true);
|
|
46
|
+
expect((0, _1.isNonZeroUint)('-0')).toBe(false);
|
|
47
|
+
expect((0, _1.isNonZeroUint)('-1')).toBe(false);
|
|
48
|
+
expect((0, _1.isNonZeroUint)('1.00')).toBe(false);
|
|
49
|
+
expect((0, _1.isNonZeroUint)('.001')).toBe(false);
|
|
50
|
+
expect((0, _1.isNonZeroUint)(' 1 ')).toBe(false);
|
|
51
|
+
expect((0, _1.isNonZeroUint)('- 1')).toBe(false);
|
|
52
52
|
});
|
|
53
53
|
test('quantity', () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
expect((0, _1.isQuantity)('0px', ['px', 'em'])).toBe(true);
|
|
55
|
+
expect((0, _1.isQuantity)('.5px', ['px', 'em'])).toBe(true);
|
|
56
|
+
expect((0, _1.isQuantity)('1.5em', ['px', 'em'])).toBe(true);
|
|
57
|
+
expect((0, _1.isQuantity)('1.5cm', ['px', 'em'])).toBe(false);
|
|
58
|
+
expect((0, _1.isQuantity)('1.5px', ['px', 'em'], 'int')).toBe(false);
|
|
59
|
+
expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'int')).toBe(true);
|
|
60
|
+
expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'uint')).toBe(false);
|
|
61
|
+
expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'float')).toBe(true);
|
|
62
|
+
expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'int')).toBe(false);
|
|
63
63
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
const is_bcp_47_1 = require(
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
const is_bcp_47_1 = require('./is-bcp-47');
|
|
5
5
|
const is = (0, is_bcp_47_1.isBCP47)();
|
|
6
6
|
test('en-us', () => {
|
|
7
|
-
|
|
7
|
+
expect(is('en-us')).toBe(true);
|
|
8
8
|
});
|
|
9
9
|
test('ja-JP', () => {
|
|
10
|
-
|
|
10
|
+
expect(is('ja-JP')).toBe(true);
|
|
11
11
|
});
|
|
12
12
|
test('Empty', () => {
|
|
13
|
-
|
|
13
|
+
expect(is('')).toBe(false);
|
|
14
14
|
});
|
|
15
15
|
test('Invalid', () => {
|
|
16
|
-
|
|
16
|
+
expect(is(':::')).toBe(false);
|
|
17
17
|
});
|
|
18
18
|
test('Surrounded by spaces', () => {
|
|
19
|
-
|
|
19
|
+
expect(is(' en ')).toBe(false);
|
|
20
20
|
});
|