@@ -2,80 +2,87 @@ import assert from 'node:assert/strict'
2
2
import test from 'node:test'
3
3
import { u } from 'unist-builder'
4
4
import { toString } from './index.js'
5
- import * as mod from './index.js'
6
5
7
- test ( 'toString' , ( ) => {
8
- assert . deepEqual (
9
- Object . keys ( mod ) . sort ( ) ,
10
- [ 'toString' ] ,
11
- 'should expose the public api'
12
- )
6
+ test ( 'toString' , async function ( t ) {
7
+ await t . test ( 'should expose the public api' , async function ( ) {
8
+ assert . deepEqual ( Object . keys ( await import ( './index.js' ) ) . sort ( ) , [
9
+ 'toString'
10
+ ] )
11
+ } )
13
12
14
- assert . throws (
15
- ( ) => {
16
- // @ts -expect-error: runtime.
13
+ await t . test ( 'should throw when not given a node (#1)' , async function ( ) {
14
+ assert . throws ( function ( ) {
15
+ // @ts -expect-error: check how the runtime handles no node .
17
16
toString ( )
18
- } ,
19
- / u n d e f i n e d / ,
20
- 'should throw when not given a node (#1)'
21
- )
17
+ } )
18
+ } )
22
19
23
- assert . throws (
24
- ( ) => {
25
- // @ts -expect-error: missing `type`.
20
+ await t . test ( 'should throw when not given a node (#2)' , async function ( ) {
21
+ assert . throws ( function ( ) {
22
+ // @ts -expect-error: check how the runtime handles no `type`.
26
23
toString ( { value : 'foo' } )
27
- } ,
28
- / \[ o b j e c t O b j e c t ] / ,
29
- 'should throw when not given a node (#2)'
30
- )
24
+ } )
25
+ } )
31
26
32
- assert . equal ( toString ( u ( 'TextNode' , 'AT' ) ) , 'AT' , 'should support texts' )
27
+ await t . test ( 'should support texts' , async function ( ) {
28
+ assert . equal ( toString ( u ( 'TextNode' , 'AT' ) ) , 'AT' )
29
+ } )
33
30
34
- assert . equal (
35
- toString (
36
- u ( 'WordNode' , [
37
- u ( 'TextNode' , 'AT' ) ,
38
- u ( 'SymbolNode' , '&' ) ,
39
- u ( 'TextNode' , 'T' )
40
- ] )
41
- ) ,
42
- 'AT&T' ,
43
- 'should support parents'
44
- )
31
+ await t . test ( 'should support parents' , async function ( ) {
32
+ assert . equal (
33
+ toString (
34
+ u ( 'WordNode' , [
35
+ u ( 'TextNode' , 'AT' ) ,
36
+ u ( 'SymbolNode' , '&' ) ,
37
+ u ( 'TextNode' , 'T' )
38
+ ] )
39
+ ) ,
40
+ 'AT&T'
41
+ )
42
+ } )
45
43
46
- assert . equal (
47
- toString ( [ u ( 'TextNode' , 'AT' ) , u ( 'SymbolNode' , '&' ) , u ( 'TextNode' , 'T' ) ] ) ,
48
- 'AT&T' ,
49
- 'should support nodes'
50
- )
44
+ await t . test ( 'should support nodes' , async function ( ) {
45
+ assert . equal (
46
+ toString ( [ u ( 'TextNode' , 'AT' ) , u ( 'SymbolNode' , '&' ) , u ( 'TextNode' , 'T' ) ] ) ,
47
+ 'AT&T'
48
+ )
49
+ } )
51
50
52
- assert . equal (
53
- toString (
54
- // @ts -expect-error: custom.
55
- u ( 'WordNode' , [
56
- u ( 'TextNode' , 'AT' ) ,
57
- u ( 'SomeNode' , [ u ( 'TextNode ' , '&' ) ] ) ,
58
- u ( 'TextNode' , 'T' )
59
- ] )
60
- ) ,
61
- 'AT&T' ,
62
- 'should support parents with mixed children'
63
- )
51
+ await t . test ( 'should support parents with mixed children' , async function ( ) {
52
+ assert . equal (
53
+ toString (
54
+ u ( 'WordNode' , [
55
+ u ( 'TextNode' , 'AT' ) ,
56
+ u ( 'SymbolNode ' , '&' ) ,
57
+ u ( 'TextNode' , 'T' )
58
+ ] )
59
+ ) ,
60
+ 'AT&T'
61
+ )
62
+ } )
64
63
65
- assert . equal (
66
- toString (
67
- // @ts -expect-error: custom.
68
- u ( 'WordNode' , [
69
- u ( 'TextNode' , 'AT' ) ,
70
- u ( 'WordNode' , [ u ( 'TextNode ' , '&' ) ] ) ,
71
- u ( 'TextNode' , 'T' )
72
- ] ) ,
73
- ','
74
- ) ,
75
- 'AT,&,T' ,
76
- 'should support separators'
77
- )
64
+ await t . test ( 'should support separators' , async function ( ) {
65
+ assert . equal (
66
+ toString (
67
+ u ( 'WordNode' , [
68
+ u ( 'TextNode' , 'AT' ) ,
69
+ u ( 'SymbolNode ' , '&' ) ,
70
+ u ( 'TextNode' , 'T' )
71
+ ] ) ,
72
+ ','
73
+ ) ,
74
+ 'AT,&,T'
75
+ )
76
+ } )
78
77
79
- // @ts -expect-error: custom node.
80
- assert . equal ( toString ( u ( 'VoidNode' ) ) , '' , 'should support voids' )
78
+ await t . test ( 'should support voids' , async function ( ) {
79
+ assert . equal (
80
+ toString (
81
+ // @ts -expect-error: check how the runtime handles custom nodes.
82
+
83
+ u ( 'VoidNode' )
84
+ ) ,
85
+ ''
86
+ )
87
+ } )
81
88
} )
0 commit comments