1- import test from 'tape'
1+ import assert from 'node:assert/strict'
2+ import test from 'node:test'
23import { x } from '../index.js'
34
4- test ( 'xastscript' , ( t ) => {
5- t . equal ( typeof x , 'function' , 'should expose a function' )
5+ test ( 'xastscript' , ( ) => {
6+ assert . equal ( typeof x , 'function' , 'should expose a function' )
67
7- t . deepEqual (
8+ assert . deepEqual (
89 x ( ) ,
910 { type : 'root' , children : [ ] } ,
1011 'should create a root when w/o `name`'
1112 )
1213
13- t . throws (
14+ assert . throws (
1415 ( ) => {
1516 // @ts -expect-error runtime.
1617 x ( 1 )
@@ -19,31 +20,31 @@ test('xastscript', (t) => {
1920 'should throw w/ incorrect `name`'
2021 )
2122
22- t . deepEqual (
23+ assert . deepEqual (
2324 x ( 'y' ) ,
2425 { type : 'element' , name : 'y' , attributes : { } , children : [ ] } ,
2526 'should create an element when given `name`'
2627 )
2728
28- t . deepEqual (
29+ assert . deepEqual (
2930 x ( 'Y' ) ,
3031 { type : 'element' , name : 'Y' , attributes : { } , children : [ ] } ,
3132 'should treat `name` case-sensitive'
3233 )
3334
34- t . deepEqual (
35+ assert . deepEqual (
3536 x ( 'y' , { a : 'b' } ) ,
3637 { type : 'element' , name : 'y' , attributes : { a : 'b' } , children : [ ] } ,
3738 'should create an element with given attributes'
3839 )
3940
40- t . deepEqual (
41+ assert . deepEqual (
4142 x ( 'y' , { a : null , b : undefined , c : Number . NaN } ) ,
4243 { type : 'element' , name : 'y' , attributes : { } , children : [ ] } ,
4344 'should ignore null, undefined, and NaN attribute values'
4445 )
4546
46- t . deepEqual (
47+ assert . deepEqual (
4748 x ( 'y' , { } , x ( 'z' ) ) ,
4849 {
4950 type : 'element' ,
@@ -54,7 +55,7 @@ test('xastscript', (t) => {
5455 'should add a child'
5556 )
5657
57- t . deepEqual (
58+ assert . deepEqual (
5859 x ( 'y' , { } , [ x ( 'a' ) , x ( 'b' ) ] ) ,
5960 {
6061 type : 'element' ,
@@ -68,7 +69,7 @@ test('xastscript', (t) => {
6869 'should add children as an array'
6970 )
7071
71- t . deepEqual (
72+ assert . deepEqual (
7273 // @ts -expect-error Deeply nested children are not typed.
7374 x ( 'y' , { } , [ [ [ x ( 'a' ) ] ] , [ [ [ [ x ( 'b' ) ] ] , x ( 'c' ) ] ] ] ) ,
7475 {
@@ -84,7 +85,7 @@ test('xastscript', (t) => {
8485 'should add children in a deeply nested array'
8586 )
8687
87- t . deepEqual (
88+ assert . deepEqual (
8889 x ( 'y' , { } , x ( 'a' ) , x ( 'b' ) ) ,
8990 {
9091 type : 'element' ,
@@ -98,7 +99,7 @@ test('xastscript', (t) => {
9899 'should add children as arguments'
99100 )
100101
101- t . deepEqual (
102+ assert . deepEqual (
102103 x ( 'y' , { } , 'a' , 1 ) ,
103104 {
104105 type : 'element' ,
@@ -112,13 +113,13 @@ test('xastscript', (t) => {
112113 'should add strings and numbers as literals'
113114 )
114115
115- t . deepEqual (
116+ assert . deepEqual (
116117 x ( 'y' , { } , null , undefined ) ,
117118 { type : 'element' , name : 'y' , attributes : { } , children : [ ] } ,
118119 'should ignore null and undefined children'
119120 )
120121
121- t . throws (
122+ assert . throws (
122123 ( ) => {
123124 // @ts -expect-error runtime.
124125 x ( 'y' , { } , { } )
@@ -127,7 +128,7 @@ test('xastscript', (t) => {
127128 'should throw on invalid children'
128129 )
129130
130- t . deepEqual (
131+ assert . deepEqual (
131132 x ( 'y' , 'z' ) ,
132133 {
133134 type : 'element' ,
@@ -138,7 +139,7 @@ test('xastscript', (t) => {
138139 'should support omitting attributes when given a string for a child'
139140 )
140141
141- t . deepEqual (
142+ assert . deepEqual (
142143 x ( 'y' , 1 ) ,
143144 {
144145 type : 'element' ,
@@ -149,7 +150,7 @@ test('xastscript', (t) => {
149150 'should support omitting attributes when given a number for a child'
150151 )
151152
152- t . deepEqual (
153+ assert . deepEqual (
153154 x ( 'y' , [ 'a' , 1 ] ) ,
154155 {
155156 type : 'element' ,
@@ -163,19 +164,19 @@ test('xastscript', (t) => {
163164 'should support omitting attributes when given an array for a child'
164165 )
165166
166- t . deepEqual (
167+ assert . deepEqual (
167168 x ( null , '1' ) ,
168169 { type : 'root' , children : [ { type : 'text' , value : '1' } ] } ,
169170 'should create a root with a textual child'
170171 )
171172
172- t . deepEqual (
173+ assert . deepEqual (
173174 x ( null , 1 ) ,
174175 { type : 'root' , children : [ { type : 'text' , value : '1' } ] } ,
175176 'should create a root with a numerical child'
176177 )
177178
178- t . deepEqual (
179+ assert . deepEqual (
179180 x ( null , x ( 'a' ) ) ,
180181 {
181182 type : 'root' ,
@@ -184,7 +185,7 @@ test('xastscript', (t) => {
184185 'should create a root with a node child'
185186 )
186187
187- t . deepEqual (
188+ assert . deepEqual (
188189 x ( 'a' , { } , [ x ( null , x ( 'b' ) ) ] ) ,
189190 {
190191 type : 'element' ,
@@ -194,6 +195,4 @@ test('xastscript', (t) => {
194195 } ,
195196 'should create a node w/ by unraveling roots'
196197 )
197-
198- t . end ( )
199198} )
0 commit comments