Skip to content

Commit a7177b9

Browse files
committed
Move to node test runner
1 parent b04c037 commit a7177b9

3 files changed

Lines changed: 37 additions & 74 deletions

File tree

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"license": "MIT",
1414
"repository": "postcss/postcss-safe-parser",
1515
"scripts": {
16-
"unit": "uvu . '\\.test\\.js$'",
16+
"unit": "node --test test/parse.test.js",
1717
"test:unit": "pnpm unit",
1818
"test:lint": "eslint .",
1919
"test:integration": "node test/integration.js",
@@ -52,8 +52,7 @@
5252
"eslint-plugin-prefer-let": "^3.0.1",
5353
"eslint-plugin-promise": "^6.1.1",
5454
"postcss": "^8.4.31",
55-
"postcss-parser-tests": "^8.8.0",
56-
"uvu": "^0.5.6"
55+
"postcss-parser-tests": "^8.8.0"
5756
},
5857
"prettier": {
5958
"arrowParens": "avoid",

pnpm-lock.yaml

Lines changed: 0 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/parse.test.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
let { eachTest, jsonify } = require('postcss-parser-tests')
2-
let { equal, not } = require('uvu/assert')
3-
let { test } = require('uvu')
2+
let { deepStrictEqual, equal } = require('node:assert')
3+
let { test } = require('node:test')
44

55
let parse = require('../lib/safe-parse')
66

77
eachTest((name, css, json) => {
88
if (name !== 'apply.css' && name !== 'custom-properties.css') {
99
test('parses ' + name, () => {
1010
let parsed = jsonify(parse(css, { from: name }))
11-
equal(parsed, json)
11+
deepStrictEqual(parsed, json)
1212
})
1313
}
1414
})
@@ -73,9 +73,7 @@ test('fixes property without semicolon in safe mode', () => {
7373
})
7474

7575
test('does not fall on missed semicolon in IE filter', () => {
76-
not.throws(() => {
77-
parse("a { one: two: progid:DX(a='1', b='2'); }")
78-
})
76+
parse("a { one: two: progid:DX(a='1', b='2'); }")
7977
})
8078

8179
test('fixes double colon in safe mode', () => {
@@ -89,37 +87,50 @@ test('fixes colon instead of semicolon', () => {
8987
})
9088

9189
test('fixes {} error', () => {
92-
let root = parse(`:root { --example-var: { "Version": { "Build": "10.30.7.350828.20230224122352", "Source": "10.30.7.350828.1", "Required": "10.30.7.307232"; }}}; @font-face { font-family: 'Calibri'; }`)
93-
equal(root.toString(), `:root { --example-var: { "Version": { "Build": "10.30.7.350828.20230224122352", "Source": "10.30.7.350828.1", "Required": "10.30.7.307232"; }}}; @font-face { font-family: 'Calibri'; }`)
90+
let root = parse(
91+
`:root { --example-var: { "Version": { "Build": "10.30.7.350828.20230224122352", "Source": "10.30.7.350828.1", "Required": "10.30.7.307232"; }}}; @font-face { font-family: 'Calibri'; }`
92+
)
93+
equal(
94+
root.toString(),
95+
`:root { --example-var: { "Version": { "Build": "10.30.7.350828.20230224122352", "Source": "10.30.7.350828.1", "Required": "10.30.7.307232"; }}}; @font-face { font-family: 'Calibri'; }`
96+
)
9497
})
9598

9699
test('Rule at the start of tokens', () => {
97-
let root = parse(`.start { font-size: 16px; }`);
98-
equal(root.toString(), `.start { font-size: 16px; }`);
99-
});
100+
let root = parse(`.start { font-size: 16px; }`)
101+
equal(root.toString(), `.start { font-size: 16px; }`)
102+
})
100103

101104
test('Complex nested structures with JSON-like properties', () => {
102-
let root = parse(`:root { --complex: {"nested": {"key": "value"}, "array": [1, {"sub": "value"}]}; } @font-face { font-family: 'Calibri'; }`);
103-
equal(root.toString(), `:root { --complex: {"nested": {"key": "value"}, "array": [1, {"sub": "value"}]}; } @font-face { font-family: 'Calibri'; }`);
104-
});
105+
let root = parse(
106+
`:root { --complex: {"nested": {"key": "value"}, "array": [1, {"sub": "value"}]}; } @font-face { font-family: 'Calibri'; }`
107+
)
108+
equal(
109+
root.toString(),
110+
`:root { --complex: {"nested": {"key": "value"}, "array": [1, {"sub": "value"}]}; } @font-face { font-family: 'Calibri'; }`
111+
)
112+
})
105113

106114
test('Multiple rules with one JSON-like custom property', () => {
107115
let root = parse(`
108116
.class1 { margin: 10px; }
109117
:root { --jsonProp: {"a": 1, "b": {"c": 3}}; }
110118
.class2 { padding: 20px; }
111-
`);
112-
equal(root.toString(), `
119+
`)
120+
equal(
121+
root.toString(),
122+
`
113123
.class1 { margin: 10px; }
114124
:root { --jsonProp: {"a": 1, "b": {"c": 3}}; }
115125
.class2 { padding: 20px; }
116-
`);
117-
});
126+
`
127+
)
128+
})
118129

119130
test('Custom property at start without modifications', () => {
120-
let root = parse(`--example: {"key": "value"}; .class { color: black; }`);
121-
equal(root.toString(), `--example: {"key": "value"}; .class { color: black; }`);
122-
});
123-
124-
test.run()
125-
131+
let root = parse(`--example: {"key": "value"}; .class { color: black; }`)
132+
equal(
133+
root.toString(),
134+
`--example: {"key": "value"}; .class { color: black; }`
135+
)
136+
})

0 commit comments

Comments
 (0)