@markuplint/types 3.7.0 → 3.9.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/defs.js CHANGED
@@ -398,8 +398,16 @@ exports.types = {
398
398
  apply: '<source-size-list>',
399
399
  def: {
400
400
  'source-size-list': '[ <source-size># , ]? <source-size-value>',
401
- 'source-size': '<media-condition> <source-size-value>',
402
- 'source-size-value': '<length>',
401
+ 'source-size': '<media-condition> <source-size-value> | auto',
402
+ /**
403
+ * > Percentages are not allowed in a `<source-size-value>`,
404
+ * > to avoid confusion about what it would be relative to.
405
+ * > The 'vw' unit can be used for sizes relative to the viewport width.
406
+ *
407
+ * `<length>` doesn't allow percentages.
408
+ * @see https://csstree.github.io/docs/syntax/#Type:length
409
+ */
410
+ 'source-size-value': '<length> | auto',
403
411
  },
404
412
  },
405
413
  },
@@ -107,6 +107,7 @@ class Token {
107
107
  };
108
108
  }
109
109
  }
110
+ exports.Token = Token;
110
111
  /**
111
112
  * @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
112
113
  */
@@ -124,4 +125,3 @@ Token.WhiteSpace = 13;
124
125
  * @see https://infra.spec.whatwg.org/#ascii-whitespace
125
126
  */
126
127
  Token.whitespace = ['\u0009', '\u000A', '\u000C', '\u000D', '\u0020'];
127
- exports.Token = Token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/types",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "Type declaration and value checker",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -22,14 +22,14 @@
22
22
  "dependencies": {
23
23
  "@types/bcp-47": "1",
24
24
  "@types/css-tree": "^2.0.1",
25
- "@types/debug": "^4.1.7",
25
+ "@types/debug": "^4.1.8",
26
26
  "@types/whatwg-mimetype": "3.0.0",
27
27
  "bcp-47": "1",
28
28
  "css-tree": "^2.3.1",
29
29
  "debug": "^4.3.4",
30
30
  "leven": "3",
31
- "type-fest": "^3.10.0",
31
+ "type-fest": "^3.12.0",
32
32
  "whatwg-mimetype": "^3.0.0"
33
33
  },
34
- "gitHead": "af370797bfc887e5a5a2ff57fbaa8392ac98ead2"
34
+ "gitHead": "4ab20276db48a6acb29a923ea8666890ca853442"
35
35
  }
@@ -13,8 +13,8 @@ test('Extends', () => {
13
13
  apply: '<source-size-list>',
14
14
  def: {
15
15
  'source-size-list': '[ <source-size># , ]? <source-size-value>',
16
- 'source-size': '<media-condition> <source-size-value>',
17
- 'source-size-value': '<length>',
16
+ 'source-size': '<media-condition> <source-size-value> | auto',
17
+ 'source-size-value': '<length> | auto',
18
18
  },
19
19
  },
20
20
  };
@@ -22,6 +22,11 @@ test('Extends', () => {
22
22
  expect(cssSyntaxMatch('(max-width: 600px) 200px, 50vw', sourceSizeList).matched).toBe(true);
23
23
  expect(cssSyntaxMatch('print 300vw', sourceSizeList).matched).toBe(false);
24
24
  expect(cssSyntaxMatch('(max-width: 600px) 200px', sourceSizeList).matched).toBe(false);
25
+ expect(cssSyntaxMatch('100vw', sourceSizeList).matched).toBe(true);
26
+ expect(cssSyntaxMatch('auto', sourceSizeList).matched).toBe(true);
27
+ expect(cssSyntaxMatch('auto, auto', sourceSizeList).matched).toBe(true);
28
+ expect(cssSyntaxMatch('auto, 100vw', sourceSizeList).matched).toBe(true);
29
+ expect(cssSyntaxMatch('auto, 100%', sourceSizeList).matched).toBe(false);
25
30
  expect(
26
31
  cssSyntaxMatch('(max-width: 600px) 200px', {
27
32
  ...sourceSizeList,
@@ -1 +0,0 @@
1
- export {};
package/lib/check.spec.js DELETED
@@ -1,82 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const check_1 = require('./check');
5
- test('Any', () => {
6
- expect((0, check_1.check)('', 'Any').matched).toBe(true);
7
- expect((0, check_1.check)(' ', 'Any').matched).toBe(true);
8
- expect((0, check_1.check)('a', 'Any').matched).toBe(true);
9
- });
10
- test('NoEmptyAny', () => {
11
- expect((0, check_1.check)('', 'NoEmptyAny').matched).toBe(false);
12
- expect((0, check_1.check)(' ', 'NoEmptyAny').matched).toBe(true);
13
- expect((0, check_1.check)('a', 'NoEmptyAny').matched).toBe(true);
14
- });
15
- test('OneLineAny', () => {
16
- expect((0, check_1.check)('', 'OneLineAny').matched).toBe(true);
17
- expect((0, check_1.check)(' ', 'OneLineAny').matched).toBe(true);
18
- expect((0, check_1.check)('a', 'OneLineAny').matched).toBe(true);
19
- expect((0, check_1.check)('a ', 'OneLineAny').matched).toBe(true);
20
- expect((0, check_1.check)('a b', 'OneLineAny').matched).toBe(true);
21
- expect((0, check_1.check)('a\n', 'OneLineAny').matched).toBe(false);
22
- expect((0, check_1.check)('a\nb', 'OneLineAny').matched).toBe(false);
23
- expect((0, check_1.check)('a\r\nb', 'OneLineAny').matched).toBe(false);
24
- expect((0, check_1.check)('a\rb', 'OneLineAny').matched).toBe(false);
25
- });
26
- test('Pattern', () => {
27
- expect((0, check_1.check)('.*', 'Pattern').matched).toBe(true);
28
- expect((0, check_1.check)('[a-z]+', 'Pattern').matched).toBe(true);
29
- expect((0, check_1.check)(']//[()?!+*', 'Pattern').matched).toBe(false);
30
- });
31
- test('BCP47', () => {
32
- expect((0, check_1.check)('en', 'BCP47').matched).toBe(true);
33
- expect((0, check_1.check)('en-US', 'BCP47').matched).toBe(true);
34
- expect((0, check_1.check)('ja', 'BCP47').matched).toBe(true);
35
- expect((0, check_1.check)(' ja ', 'BCP47').matched).toBe(false);
36
- expect((0, check_1.check)('', 'BCP47').matched).toBe(false);
37
- expect((0, check_1.check)('zh/cn', 'BCP47').matched).toBe(false);
38
- });
39
- test('Srcset', () => {
40
- expect((0, check_1.check)('a/bb/ccc/dddd', 'Srcset').matched).toBe(true);
41
- expect((0, check_1.check)('a/bb/ccc/dddd 200w', 'Srcset').matched).toBe(true);
42
- expect((0, check_1.check)('a/bb/ccc/dddd 200w, b/cc/ddd/eeee 1.5x', 'Srcset').matched).toBe(true);
43
- expect((0, check_1.check)('a/bb/ccc/dddd 200w, b/cc/ddd/eeee 1.5a', 'Srcset').matched).toBe(false);
44
- });
45
- test('IconSize', () => {
46
- expect((0, check_1.check)('any', 'IconSize').matched).toBe(true);
47
- expect((0, check_1.check)('Any', 'IconSize').matched).toBe(true);
48
- expect((0, check_1.check)('10x10', 'IconSize').matched).toBe(true);
49
- expect((0, check_1.check)('1x1', 'IconSize').matched).toBe(true);
50
- expect((0, check_1.check)('1x0', 'IconSize').matched).toBe(false);
51
- expect((0, check_1.check)('0x1', 'IconSize').matched).toBe(false);
52
- expect((0, check_1.check)('0x0', 'IconSize').matched).toBe(false);
53
- expect((0, check_1.check)('', 'IconSize').matched).toBe(false);
54
- expect((0, check_1.check)(' ', 'IconSize').matched).toBe(false);
55
- expect((0, check_1.check)('1', 'IconSize').matched).toBe(false);
56
- expect((0, check_1.check)('1x', 'IconSize').matched).toBe(false);
57
- expect((0, check_1.check)('x1', 'IconSize').matched).toBe(false);
58
- });
59
- test('Number', () => {
60
- expect((0, check_1.check)('10', { type: 'integer', gt: 0 }).matched).toBe(true);
61
- expect((0, check_1.check)('0', { type: 'integer', gt: 0 }).matched).toBe(false);
62
- expect((0, check_1.check)('0', { type: 'integer', gte: 0 }).matched).toBe(true);
63
- expect((0, check_1.check)('9', { type: 'integer', lt: 10 }).matched).toBe(true);
64
- expect((0, check_1.check)('10', { type: 'integer', lt: 10 }).matched).toBe(false);
65
- });
66
- test('Non-exist types', () => {
67
- // @ts-ignore
68
- expect((0, check_1.check)('abc', 'String').matched).toBe(true);
69
- // @ts-ignore
70
- expect((0, check_1.check)('abc', 'FooBar').matched).toBe(true);
71
- // @ts-ignore
72
- expect((0, check_1.check)('abc', ' ').matched).toBe(true);
73
- // @ts-ignore
74
- expect((0, check_1.check)('abc', '\n').matched).toBe(true);
75
- // @ts-ignore
76
- expect((0, check_1.check)('abc', '').matched).toBe(true);
77
- });
78
- test('ItemProp', () => {
79
- expect((0, check_1.check)('itemListElement', 'ItemProp').matched).toBe(true);
80
- expect((0, check_1.check)('item', 'ItemProp').matched).toBe(true);
81
- expect((0, check_1.check)('position', 'ItemProp').matched).toBe(true);
82
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,160 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const css_syntax_1 = require('./css-syntax');
5
- test('CSS Standard', () => {
6
- expect((0, css_syntax_1.cssSyntaxMatch)('10px', '<length>').matched).toBe(true);
7
- expect((0, css_syntax_1.cssSyntaxMatch)('one-pixel', '<length>').matched).toBe(false);
8
- expect((0, css_syntax_1.cssSyntaxMatch)('(prefers-color-scheme: dark)', '<media-query-list>').matched).toBe(true);
9
- });
10
- test('Extends', () => {
11
- const sourceSizeList = {
12
- ref: 'https://html.spec.whatwg.org/multipage/images.html#sizes-attributes',
13
- syntax: {
14
- apply: '<source-size-list>',
15
- def: {
16
- 'source-size-list': '[ <source-size># , ]? <source-size-value>',
17
- 'source-size': '<media-condition> <source-size-value>',
18
- 'source-size-value': '<length>',
19
- },
20
- },
21
- };
22
- expect((0, css_syntax_1.cssSyntaxMatch)('50vw', sourceSizeList).matched).toBe(true);
23
- expect((0, css_syntax_1.cssSyntaxMatch)('(max-width: 600px) 200px, 50vw', sourceSizeList).matched).toBe(true);
24
- expect((0, css_syntax_1.cssSyntaxMatch)('print 300vw', sourceSizeList).matched).toBe(false);
25
- expect((0, css_syntax_1.cssSyntaxMatch)('(max-width: 600px) 200px', sourceSizeList).matched).toBe(false);
26
- expect(
27
- (0, css_syntax_1.cssSyntaxMatch)('(max-width: 600px) 200px', {
28
- ...sourceSizeList,
29
- syntax: {
30
- ...sourceSizeList.syntax,
31
- apply: '<source-size>',
32
- },
33
- }).matched,
34
- ).toBe(true);
35
- const keyTimes = {
36
- ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
37
- syntax: {
38
- apply: '<key-times>',
39
- def: {
40
- 'key-times': '<number> [; <number>]* [;]?',
41
- },
42
- },
43
- };
44
- expect((0, css_syntax_1.cssSyntaxMatch)('20; 20; 30', keyTimes).matched).toBe(true);
45
- expect((0, css_syntax_1.cssSyntaxMatch)('20; 20; 30;', keyTimes).matched).toBe(true);
46
- expect((0, css_syntax_1.cssSyntaxMatch)('20; 20; abc;', keyTimes).matched).toBe(false);
47
- expect((0, css_syntax_1.cssSyntaxMatch)('20; 20; ;', keyTimes).matched).toBe(false);
48
- const SVGViewBox = {
49
- ref: 'https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute',
50
- syntax: {
51
- apply: '<view-box>',
52
- def: {
53
- 'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>',
54
- 'min-x': '<number>',
55
- 'min-y': '<number>',
56
- width: '<number>',
57
- height: '<number>',
58
- },
59
- },
60
- };
61
- expect((0, css_syntax_1.cssSyntaxMatch)('0 0 30 10', SVGViewBox).matched).toBe(true);
62
- expect((0, css_syntax_1.cssSyntaxMatch)('0 0, 30, 10', SVGViewBox).matched).toBe(true);
63
- expect((0, css_syntax_1.cssSyntaxMatch)('0 0, 30', SVGViewBox).matched).toBe(false);
64
- const percentageList = {
65
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage',
66
- syntax: {
67
- apply: '<percentage-list>',
68
- def: {
69
- 'percentage-list': '[ <number> [,]? ]* <number>',
70
- },
71
- },
72
- };
73
- expect((0, css_syntax_1.cssSyntaxMatch)('0 0 30 10', percentageList).matched).toBe(true);
74
- expect((0, css_syntax_1.cssSyntaxMatch)('0, 0, 30 10', percentageList).matched).toBe(true);
75
- expect((0, css_syntax_1.cssSyntaxMatch)('0', percentageList).matched).toBe(true);
76
- expect((0, css_syntax_1.cssSyntaxMatch)('', percentageList).matched).toBe(false);
77
- const custom = {
78
- ref: 'n/a',
79
- syntax: {
80
- apply: '<custom>',
81
- def: {
82
- custom: '0 | 1 | .',
83
- },
84
- },
85
- };
86
- expect((0, css_syntax_1.cssSyntaxMatch)('0', custom).matched).toBe(true);
87
- expect((0, css_syntax_1.cssSyntaxMatch)('1', custom).matched).toBe(true);
88
- expect((0, css_syntax_1.cssSyntaxMatch)('.', custom).matched).toBe(true);
89
- expect((0, css_syntax_1.cssSyntaxMatch)('2', custom).matched).toBe(false);
90
- expect((0, css_syntax_1.cssSyntaxMatch)(':', custom).matched).toBe(false);
91
- });
92
- test('custom-type-checking', () => {
93
- const custom = {
94
- ref: 'n/a',
95
- caseSensitive: true,
96
- syntax: {
97
- apply: '<custom>',
98
- def: {
99
- custom: '<custom-type>',
100
- 'custom-type': token => {
101
- if (!token) {
102
- return 0;
103
- }
104
- return token.value === '1' ? 1 : 0;
105
- },
106
- },
107
- },
108
- };
109
- expect((0, css_syntax_1.cssSyntaxMatch)('1', custom).matched).toBe(true);
110
- expect((0, css_syntax_1.cssSyntaxMatch)('0', custom).matched).toBe(false);
111
- });
112
- test('case-sensitive', () => {
113
- const custom = {
114
- ref: 'n/a',
115
- caseSensitive: true,
116
- syntax: {
117
- apply: '<custom>',
118
- def: {
119
- custom: 'CaSeS [a | B | aBc]',
120
- },
121
- },
122
- };
123
- expect((0, css_syntax_1.cssSyntaxMatch)('CaSeS a', custom).matched).toBe(true);
124
- expect((0, css_syntax_1.cssSyntaxMatch)('CaSeS B', custom).matched).toBe(true);
125
- expect((0, css_syntax_1.cssSyntaxMatch)('CaSeS aBc', custom).matched).toBe(true);
126
- expect((0, css_syntax_1.cssSyntaxMatch)('CaSeS A', custom)).toStrictEqual({
127
- column: 7,
128
- line: 1,
129
- matched: false,
130
- length: 1,
131
- offset: 6,
132
- partName: 'value',
133
- raw: 'A',
134
- reason: 'syntax-error',
135
- ref: 'n/a',
136
- expects: [
137
- {
138
- type: 'syntax',
139
- value: '<custom>',
140
- },
141
- ],
142
- });
143
- expect((0, css_syntax_1.cssSyntaxMatch)('CaSeS abc', custom)).toStrictEqual({
144
- column: 7,
145
- line: 1,
146
- matched: false,
147
- length: 3,
148
- offset: 6,
149
- partName: 'value',
150
- raw: 'abc',
151
- reason: 'syntax-error',
152
- ref: 'n/a',
153
- expects: [
154
- {
155
- type: 'syntax',
156
- value: '<custom>',
157
- },
158
- ],
159
- });
160
- });
@@ -1 +0,0 @@
1
- export {};
package/lib/list.spec.js DELETED
@@ -1,130 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const list_1 = require('./list');
5
- test('Zero space', () => {
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
- });
22
- test('Zero comma', () => {
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
- });
35
- test('Zero comma (disallowToSurroundBySpaces)', () => {
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
- });
49
- test('Location of the token', () => {
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
- });
91
- test('Expected comma', () => {
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
- });
116
- test('Missing comma', () => {
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const _1 = require('.');
5
- test('int', () => {
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
- });
17
- test('uint', () => {
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
- });
29
- test('float', () => {
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
- });
41
- test('nonZeroUint', () => {
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
- });
53
- test('quantity', () => {
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const is_bcp_47_1 = require('./is-bcp-47');
5
- const is = (0, is_bcp_47_1.isBCP47)();
6
- test('en-us', () => {
7
- expect(is('en-us')).toBe(true);
8
- });
9
- test('ja-JP', () => {
10
- expect(is('ja-JP')).toBe(true);
11
- });
12
- test('Empty', () => {
13
- expect(is('')).toBe(false);
14
- });
15
- test('Invalid', () => {
16
- expect(is(':::')).toBe(false);
17
- });
18
- test('Surrounded by spaces', () => {
19
- expect(is(' en ')).toBe(false);
20
- });
@@ -1 +0,0 @@
1
- export {};