11let { 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
55let parse = require ( '../lib/safe-parse' )
66
77eachTest ( ( 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
7575test ( '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
8179test ( 'fixes double colon in safe mode' , ( ) => {
@@ -89,37 +87,50 @@ test('fixes colon instead of semicolon', () => {
8987} )
9088
9189test ( '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
9699test ( '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
101104test ( '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
106114test ( '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
119130test ( '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