@@ -2,63 +2,72 @@ 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 . deepEqual (
15
- toString ( u ( 'cdata' , '<greeting>Hello, world!</greeting>' ) ) ,
16
- '<greeting>Hello, world!</greeting>' ,
17
- 'should serialize cdata'
18
- )
13
+ await t . test ( 'should serialize cdata' , async function ( ) {
14
+ assert . deepEqual (
15
+ toString ( u ( 'cdata' , '<greeting>Hello, world!</greeting>' ) ) ,
16
+ '<greeting>Hello, world!</greeting>'
17
+ )
18
+ } )
19
19
20
- assert . deepEqual (
21
- toString ( u ( 'comment' , 'foo' ) ) ,
22
- 'foo' ,
23
- 'should serialize comments'
24
- )
20
+ await t . test ( 'should serialize comments' , async function ( ) {
21
+ assert . deepEqual ( toString ( u ( 'comment' , 'foo' ) ) , 'foo' )
22
+ } )
25
23
26
- assert . deepEqual (
27
- toString ( u ( 'instruction' , { name : 'xml' } , 'version="1.0" encoding="UTF-8"' ) ) ,
28
- 'version="1.0" encoding="UTF-8"' ,
29
- 'should serialize instructions'
30
- )
24
+ await t . test ( 'should serialize instructions' , async function ( ) {
25
+ assert . deepEqual (
26
+ toString (
27
+ u ( 'instruction' , { name : 'xml' } , 'version="1.0" encoding="UTF-8"' )
28
+ ) ,
29
+ 'version="1.0" encoding="UTF-8"'
30
+ )
31
+ } )
31
32
32
- assert . deepEqual ( toString ( u ( 'text' , 'foo' ) ) , 'foo' , 'should serialize texts' )
33
+ await t . test ( 'should serialize texts' , async function ( ) {
34
+ assert . deepEqual ( toString ( u ( 'text' , 'foo' ) ) , 'foo' )
35
+ } )
33
36
34
- assert . deepEqual (
35
- toString ( u ( 'doctype' , { name : 'html' } ) ) ,
36
- '' ,
37
- 'should return empty for doctypes'
38
- )
37
+ await t . test ( 'should return empty for doctypes' , async function ( ) {
38
+ assert . deepEqual ( toString ( u ( 'doctype' , { name : 'html' } ) ) , '' )
39
+ } )
39
40
40
- assert . deepEqual (
41
- toString (
42
- u ( 'element' , { name : 'package' , attributes : { } } , [
43
- u ( 'text' , 'foo ' ) ,
44
- u ( 'comment' , 'bar' ) ,
45
- u ( 'element' , { name : 'thing' , attributes : { } } , [ u ( 'text' , ' baz' ) ] )
46
- ] )
47
- ) ,
48
- 'foo baz' ,
49
- 'should serialize elements (excluding non-parent and non-text descendants)'
41
+ await t . test (
42
+ 'should serialize elements (excluding non-parent and non-text descendants)' ,
43
+ async function ( ) {
44
+ assert . deepEqual (
45
+ toString (
46
+ u ( 'element' , { name : 'package' , attributes : { } } , [
47
+ u ( 'text' , 'foo ' ) ,
48
+ u ( 'comment' , 'bar' ) ,
49
+ u ( 'element' , { name : 'thing' , attributes : { } } , [ u ( 'text' , ' baz' ) ] )
50
+ ] )
51
+ ) ,
52
+ 'foo baz'
53
+ )
54
+ }
50
55
)
51
56
52
- assert . deepEqual (
53
- toString (
54
- u ( 'root' , [
55
- u ( 'doctype' , { name : 'html' } ) ,
56
- u ( 'text' , 'foo ' ) ,
57
- u ( 'comment' , 'bar' ) ,
58
- u ( 'element' , { name : 'thing' , attributes : { } } , [ u ( 'text' , ' baz' ) ] )
59
- ] )
60
- ) ,
61
- 'foo baz' ,
62
- 'should serialize roots (excluding non-parent and non-text descendants)'
57
+ await t . test (
58
+ 'should serialize roots (excluding non-parent and non-text descendants)' ,
59
+ async function ( ) {
60
+ assert . deepEqual (
61
+ toString (
62
+ u ( 'root' , [
63
+ u ( 'doctype' , { name : 'html' } ) ,
64
+ u ( 'text' , 'foo ' ) ,
65
+ u ( 'comment' , 'bar' ) ,
66
+ u ( 'element' , { name : 'thing' , attributes : { } } , [ u ( 'text' , ' baz' ) ] )
67
+ ] )
68
+ ) ,
69
+ 'foo baz'
70
+ )
71
+ }
63
72
)
64
73
} )
0 commit comments