@@ -49,7 +49,6 @@ test('sanitize()', async function (t) {
49
49
await t . test ( 'should ignore unknown nodes' , async function ( ) {
50
50
assert . equal (
51
51
toHtml (
52
- // @ts -expect-error: remove when `hast-util-to-html` updates.
53
52
sanitize (
54
53
// @ts -expect-error: check how an unknown node is
55
54
u ( 'unknown' , '<xml></xml>' )
@@ -62,23 +61,14 @@ test('sanitize()', async function (t) {
62
61
63
62
test ( '`comment`' , async function ( t ) {
64
63
await t . test ( 'should ignore `comment`s by default' , async function ( ) {
65
- assert . equal (
66
- toHtml (
67
- // @ts -expect-error: remove when `hast-util-to-html` updates.
68
- sanitize ( u ( 'comment' , 'alpha' ) )
69
- ) ,
70
- ''
71
- )
64
+ assert . equal ( toHtml ( sanitize ( u ( 'comment' , 'alpha' ) ) ) , '' )
72
65
} )
73
66
74
67
await t . test (
75
68
'should allow `comment`s with `allowComments: true`' ,
76
69
async function ( ) {
77
70
assert . equal (
78
- toHtml (
79
- // @ts -expect-error: remove when `hast-util-to-html` updates.
80
- sanitize ( u ( 'comment' , 'alpha' ) , { allowComments : true } )
81
- ) ,
71
+ toHtml ( sanitize ( u ( 'comment' , 'alpha' ) , { allowComments : true } ) ) ,
82
72
'<!--alpha-->'
83
73
)
84
74
}
@@ -102,7 +92,6 @@ test('`comment`', async function (t) {
102
92
async function ( ) {
103
93
assert . equal (
104
94
toHtml (
105
- // @ts -expect-error: remove when `hast-util-to-html` updates.
106
95
sanitize ( u ( 'comment' , 'alpha--><script>alert(1)</script><!--bravo' ) , {
107
96
allowComments : true
108
97
} )
@@ -115,19 +104,14 @@ test('`comment`', async function (t) {
115
104
116
105
test ( '`doctype`' , async function ( t ) {
117
106
await t . test ( 'should ignore `doctype`s by default' , async function ( ) {
118
- assert . equal (
119
- // @ts -expect-error: remove when `hast-util-to-html` updates.
120
- toHtml ( sanitize ( u ( 'doctype' , { name : 'html' } , 'alpha' ) ) ) ,
121
- ''
122
- )
107
+ assert . equal ( toHtml ( sanitize ( u ( 'doctype' , { name : 'html' } , 'alpha' ) ) ) , '' )
123
108
} )
124
109
125
110
await t . test (
126
111
'should allow `doctype`s with `allowDoctypes: true`' ,
127
112
async function ( ) {
128
113
assert . equal (
129
114
toHtml (
130
- // @ts -expect-error: remove when `hast-util-to-html` updates.
131
115
sanitize ( u ( 'doctype' , { name : 'html' } , 'alpha' ) , {
132
116
allowDoctypes : true
133
117
} )
@@ -168,11 +152,7 @@ test('`text`', async function (t) {
168
152
} )
169
153
170
154
await t . test ( 'should allow `text`' , async function ( ) {
171
- assert . equal (
172
- // @ts -expect-error: remove when `hast-util-to-html` updates.
173
- toHtml ( sanitize ( u ( 'text' , 'alert(1)' ) ) ) ,
174
- 'alert(1)'
175
- )
155
+ assert . equal ( toHtml ( sanitize ( u ( 'text' , 'alert(1)' ) ) ) , 'alert(1)' )
176
156
} )
177
157
178
158
await t . test ( 'should ignore non-string `value`s' , async function ( ) {
@@ -184,21 +164,12 @@ test('`text`', async function (t) {
184
164
} )
185
165
186
166
await t . test ( 'should ignore `text` in `script` elements' , async function ( ) {
187
- assert . equal (
188
- toHtml (
189
- // @ts -expect-error: remove when `hast-util-to-html` updates.
190
- sanitize ( h ( 'script' , u ( 'text' , 'alert(1)' ) ) )
191
- ) ,
192
- ''
193
- )
167
+ assert . equal ( toHtml ( sanitize ( h ( 'script' , u ( 'text' , 'alert(1)' ) ) ) ) , '' )
194
168
} )
195
169
196
170
await t . test ( 'should show `text` in `style` elements' , async function ( ) {
197
171
assert . equal (
198
- toHtml (
199
- // @ts -expect-error: remove when `hast-util-to-html` updates.
200
- sanitize ( h ( 'style' , u ( 'text' , 'alert(1)' ) ) )
201
- ) ,
172
+ toHtml ( sanitize ( h ( 'style' , u ( 'text' , 'alert(1)' ) ) ) ) ,
202
173
'alert(1)'
203
174
)
204
175
} )
0 commit comments