11var parse = require ( '../' ) . parse ;
2- var should = require ( 'should' ) ;
2+ var assert = require ( 'node:assert' ) ;
3+ var { describe, it } = require ( 'node:test' ) ;
34
45describe ( 'parse(str)' , function ( ) {
56 it ( 'should save the filename and source' , function ( ) {
@@ -8,50 +9,50 @@ describe('parse(str)', function() {
89 source : 'booty.css'
910 } ) ;
1011
11- ast . stylesheet . source . should . equal ( 'booty.css' ) ;
12+ assert . strictEqual ( ast . stylesheet . source , 'booty.css' ) ;
1213
1314 var position = ast . stylesheet . rules [ 0 ] . position ;
14- position . start . should . be . ok ;
15- position . end . should . be . ok ;
16- position . source . should . equal ( 'booty.css' ) ;
17- position . content . should . equal ( css ) ;
15+ assert . ok ( position . start ) ;
16+ assert . ok ( position . end ) ;
17+ assert . strictEqual ( position . source , 'booty.css' ) ;
18+ assert . strictEqual ( position . content , css ) ;
1819 } ) ;
1920
2021 it ( 'should throw when a selector is missing' , function ( ) {
21- should ( function ( ) {
22+ assert . throws ( function ( ) {
2223 parse ( '{size: large}' ) ;
23- } ) . throw ( ) ;
24+ } ) ;
2425
25- should ( function ( ) {
26+ assert . throws ( function ( ) {
2627 parse ( 'b { color: red; }\n{ color: green; }\na { color: blue; }' ) ;
27- } ) . throw ( ) ;
28+ } ) ;
2829 } ) ;
2930
3031 it ( 'should throw when a broken comment is found' , function ( ) {
31- should ( function ( ) {
32+ assert . throws ( function ( ) {
3233 parse ( 'thing { color: red; } /* b { color: blue; }' ) ;
33- } ) . throw ( ) ;
34+ } ) ;
3435
35- should ( function ( ) {
36+ assert . throws ( function ( ) {
3637 parse ( '/*' ) ;
37- } ) . throw ( ) ;
38+ } ) ;
3839
3940 /* Nested comments should be fine */
40- should ( function ( ) {
41+ assert . doesNotThrow ( function ( ) {
4142 parse ( '/* /* */' ) ;
42- } ) . not . throw ( ) ;
43+ } ) ;
4344 } ) ;
4445
4546 it ( 'should allow empty property value' , function ( ) {
46- should ( function ( ) {
47+ assert . doesNotThrow ( function ( ) {
4748 parse ( 'p { color:; }' ) ;
48- } ) . not . throw ( ) ;
49+ } ) ;
4950 } ) ;
5051
5152 it ( 'should not throw with silent option' , function ( ) {
52- should ( function ( ) {
53+ assert . doesNotThrow ( function ( ) {
5354 parse ( 'thing { color: red; } /* b { color: blue; }' , { silent : true } ) ;
54- } ) . not . throw ( ) ;
55+ } ) ;
5556 } ) ;
5657
5758 it ( 'should list the parsing errors and continue parsing' , function ( ) {
@@ -61,18 +62,18 @@ describe('parse(str)', function() {
6162 } ) ;
6263
6364 var rules = result . stylesheet . rules ;
64- rules . length . should . be . above ( 2 ) ;
65+ assert . ok ( rules . length > 2 ) ;
6566
6667 var errors = result . stylesheet . parsingErrors ;
67- errors . length . should . equal ( 2 ) ;
68+ assert . strictEqual ( errors . length , 2 ) ;
6869
69- errors [ 0 ] . should . have . a . property ( 'message' ) ;
70- errors [ 0 ] . should . have . a . property ( 'reason' ) ;
71- errors [ 0 ] . should . have . a . property ( 'filename' ) ;
72- errors [ 0 ] . filename . should . equal ( 'foo.css' ) ;
73- errors [ 0 ] . should . have . a . property ( 'line' ) ;
74- errors [ 0 ] . should . have . a . property ( 'column' ) ;
75- errors [ 0 ] . should . have . a . property ( 'source' ) ;
70+ assert . ok ( 'message' in errors [ 0 ] ) ;
71+ assert . ok ( 'reason' in errors [ 0 ] ) ;
72+ assert . ok ( 'filename' in errors [ 0 ] ) ;
73+ assert . strictEqual ( errors [ 0 ] . filename , 'foo.css' ) ;
74+ assert . ok ( 'line' in errors [ 0 ] ) ;
75+ assert . ok ( 'column' in errors [ 0 ] ) ;
76+ assert . ok ( 'source' in errors [ 0 ] ) ;
7677
7778 } ) ;
7879
@@ -81,28 +82,28 @@ describe('parse(str)', function() {
8182 'thing { test: value; }\n' +
8283 '@media (min-width: 100px) { thing { test: value; } }' ) ;
8384
84- should ( result . parent ) . equal ( null ) ;
85+ assert . strictEqual ( result . parent , null ) ;
8586
8687 var rules = result . stylesheet . rules ;
87- rules . length . should . equal ( 2 ) ;
88+ assert . strictEqual ( rules . length , 2 ) ;
8889
8990 var rule = rules [ 0 ] ;
90- rule . parent . should . equal ( result ) ;
91- rule . declarations . length . should . equal ( 1 ) ;
91+ assert . strictEqual ( rule . parent , result ) ;
92+ assert . strictEqual ( rule . declarations . length , 1 ) ;
9293
9394 var decl = rule . declarations [ 0 ] ;
94- decl . parent . should . equal ( rule ) ;
95+ assert . strictEqual ( decl . parent , rule ) ;
9596
9697 var media = rules [ 1 ] ;
97- media . parent . should . equal ( result ) ;
98- media . rules . length . should . equal ( 1 ) ;
98+ assert . strictEqual ( media . parent , result ) ;
99+ assert . strictEqual ( media . rules . length , 1 ) ;
99100
100101 rule = media . rules [ 0 ] ;
101- rule . parent . should . equal ( media ) ;
102+ assert . strictEqual ( rule . parent , media ) ;
102103
103- rule . declarations . length . should . equal ( 1 ) ;
104+ assert . strictEqual ( rule . declarations . length , 1 ) ;
104105 decl = rule . declarations [ 0 ] ;
105- decl . parent . should . equal ( rule ) ;
106+ assert . strictEqual ( decl . parent , rule ) ;
106107 } ) ;
107108
108109} ) ;
0 commit comments