@@ -12,124 +12,121 @@ test('fromText', async function (t) {
12
12
} )
13
13
14
14
await t . test ( 'should set text nodes' , async function ( ) {
15
- assert . deepEqual (
16
- // @ts -expect-error runtime.
17
- fromText ( u ( 'text' ) , 'foo' ) ,
18
- u ( 'text' , 'foo' )
19
- )
15
+ const node = u ( 'text' )
16
+ // @ts -expect-error: check how a missing `value` is handled.
17
+ fromText ( node , 'foo' )
18
+ assert . deepEqual ( node , u ( 'text' , 'foo' ) )
20
19
} )
21
20
22
21
await t . test ( 'should reset text nodes (1)' , async function ( ) {
23
- assert . deepEqual (
24
- // @ts -expect-error runtime.
25
- fromText ( u ( 'text' ) ) ,
26
- u ( 'text' , '' )
27
- )
22
+ const node = u ( 'text' )
23
+ // @ts -expect-error: check how a missing `value` is handled.
24
+ fromText ( node )
25
+ assert . deepEqual ( node , u ( 'text' , '' ) )
28
26
} )
29
27
30
28
await t . test ( 'should reset text nodes (2)' , async function ( ) {
31
- assert . deepEqual ( fromText ( u ( 'text' , 'foo' ) ) , u ( 'text' , '' ) )
29
+ const node = u ( 'text' , 'foo' )
30
+ fromText ( node , '' )
31
+ assert . deepEqual ( node , u ( 'text' , '' ) )
32
32
} )
33
33
34
34
await t . test ( 'should set parent nodes' , async function ( ) {
35
- assert . deepEqual ( fromText ( h ( 'p' ) , 'foo' ) , h ( 'p' , 'foo' ) )
35
+ const node = h ( 'p' )
36
+ fromText ( node , 'foo' )
37
+ assert . deepEqual ( node , h ( 'p' , 'foo' ) )
36
38
} )
37
39
38
40
await t . test (
39
41
'should set parent nodes with <br>s if ␊ is used' ,
40
42
async function ( ) {
41
- assert . deepEqual (
42
- fromText ( h ( 'p' , 'foo' ) , 'foo\nbar\nbaz' ) ,
43
- h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] )
44
- )
43
+ const node = h ( 'p' , 'foo' )
44
+ fromText ( node , 'foo\nbar\nbaz' )
45
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] ) )
45
46
}
46
47
)
47
48
48
49
await t . test (
49
50
'should set parent nodes with <br>s if ␍ is used' ,
50
51
async function ( ) {
51
- assert . deepEqual (
52
- fromText ( h ( 'p' , 'foo' ) , 'foo\rbar\rbaz' ) ,
53
- h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] )
54
- )
52
+ const node = h ( 'p' , 'foo' )
53
+ fromText ( node , 'foo\rbar\rbaz' )
54
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] ) )
55
55
}
56
56
)
57
57
58
58
await t . test (
59
59
'should set parent nodes with <br>s if ␍␊ is used' ,
60
60
async function ( ) {
61
- assert . deepEqual (
62
- fromText ( h ( 'p' , 'foo' ) , 'foo\r\nbar\r\nbaz' ) ,
63
- h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] )
64
- )
61
+ const node = h ( 'p' , 'foo' )
62
+ fromText ( node , 'foo\r\nbar\r\nbaz' )
63
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) , 'bar' , h ( 'br' ) , 'baz' ] ) )
65
64
}
66
65
)
67
66
68
67
await t . test (
69
68
'should set parent nodes with <br>s if a final ␊ is used' ,
70
69
async function ( ) {
71
- assert . deepEqual (
72
- fromText ( h ( 'p' , 'foo' ) , 'foo\n' ) ,
73
- h ( 'p' , [ 'foo' , h ( 'br' ) ] )
74
- )
70
+ const node = h ( 'p' , 'foo' )
71
+ fromText ( node , 'foo\n' )
72
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) ] ) )
75
73
}
76
74
)
77
75
78
76
await t . test (
79
77
'should set parent nodes with <br>s if a final ␍␊ is used' ,
80
78
async function ( ) {
81
- assert . deepEqual (
82
- fromText ( h ( 'p' , 'foo' ) , 'foo\r' ) ,
83
- h ( 'p' , [ 'foo' , h ( 'br' ) ] )
84
- )
79
+ const node = h ( 'p' , 'foo' )
80
+ fromText ( node , 'foo\r' )
81
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) ] ) )
85
82
}
86
83
)
87
84
88
85
await t . test (
89
86
'should set parent nodes with <br>s if a final ␍␊ is used' ,
90
87
async function ( ) {
91
- assert . deepEqual (
92
- fromText ( h ( 'p' , 'foo' ) , 'foo\r\n' ) ,
93
- h ( 'p' , [ 'foo' , h ( 'br' ) ] )
94
- )
88
+ const node = h ( 'p' , 'foo' )
89
+ fromText ( node , 'foo\r\n' )
90
+ assert . deepEqual ( node , h ( 'p' , [ 'foo' , h ( 'br' ) ] ) )
95
91
}
96
92
)
97
93
98
94
await t . test (
99
95
'should set parent nodes with <br>s if an initial ␊ is used' ,
100
96
async function ( ) {
101
- assert . deepEqual (
102
- fromText ( h ( 'p' , 'foo' ) , '\nfoo' ) ,
103
- h ( 'p' , [ h ( 'br' ) , 'foo' ] )
104
- )
97
+ const node = h ( 'p' , 'foo' )
98
+ fromText ( node , '\nfoo' )
99
+ assert . deepEqual ( node , h ( 'p' , [ h ( 'br' ) , 'foo' ] ) )
105
100
}
106
101
)
107
102
108
103
await t . test (
109
104
'should set parent nodes with <br>s if an initial ␍␊ is used' ,
110
105
async function ( ) {
111
- assert . deepEqual (
112
- fromText ( h ( 'p' , 'foo' ) , '\rfoo' ) ,
113
- h ( 'p' , [ h ( 'br' ) , 'foo' ] )
114
- )
106
+ const node = h ( 'p' , 'foo' )
107
+ fromText ( node , '\rfoo' )
108
+ assert . deepEqual ( node , h ( 'p' , [ h ( 'br' ) , 'foo' ] ) )
115
109
}
116
110
)
117
111
118
112
await t . test (
119
113
'should set parent nodes with <br>s if an initial ␍␊ is used' ,
120
114
async function ( ) {
121
- assert . deepEqual (
122
- fromText ( h ( 'p' , 'foo' ) , '\r\nfoo' ) ,
123
- h ( 'p' , [ h ( 'br' ) , 'foo' ] )
124
- )
115
+ const node = h ( 'p' , 'foo' )
116
+ fromText ( node , '\r\nfoo' )
117
+ assert . deepEqual ( node , h ( 'p' , [ h ( 'br' ) , 'foo' ] ) )
125
118
}
126
119
)
127
120
128
121
await t . test ( 'should reset parent nodes (1)' , async function ( ) {
129
- assert . deepEqual ( fromText ( h ( 'p' ) ) , h ( 'p' ) )
122
+ const node = h ( 'p' )
123
+ fromText ( node )
124
+ assert . deepEqual ( node , h ( 'p' ) )
130
125
} )
131
126
132
127
await t . test ( 'should reset parent nodes (2)' , async function ( ) {
133
- assert . deepEqual ( fromText ( h ( 'p' , 'foo' ) ) , h ( 'p' ) )
128
+ const node = h ( 'p' , 'foo' )
129
+ fromText ( node )
130
+ assert . deepEqual ( node , h ( 'p' ) )
134
131
} )
135
132
} )
0 commit comments