@@ -9,28 +9,16 @@ var fromXml = require('..')
9
9
10
10
var join = path . join
11
11
12
- test ( 'xast-util-from-xml' , function ( t ) {
12
+ test ( 'xast-util-from-xml' , function ( t ) {
13
13
t . equal ( typeof fromXml , 'function' , 'should expose a function' )
14
14
15
15
try {
16
16
fromXml ( '<root unquoted=attribute>' )
17
17
t . fail ( 'should fail (1)' )
18
18
} catch ( error ) {
19
- t . deepEqual (
20
- error ,
21
- {
22
- message : 'Unquoted attribute value' ,
23
- name : '1:17' ,
24
- reason : 'Unquoted attribute value' ,
25
- line : 1 ,
26
- column : 17 ,
27
- location : {
28
- start : { line : 1 , column : 17 , offset : 16 } ,
29
- end : { line : null , column : null }
30
- } ,
31
- source : 'xast-util-from-xml' ,
32
- ruleId : 'sax'
33
- } ,
19
+ t . equal (
20
+ String ( error ) ,
21
+ '1:17: Unquoted attribute value' ,
34
22
'should throw messages'
35
23
)
36
24
}
@@ -39,21 +27,9 @@ test('xast-util-from-xml', function(t) {
39
27
fromXml ( '<!ENTITY>' )
40
28
t . fail ( 'should fail (2)' )
41
29
} catch ( error ) {
42
- t . deepEqual (
43
- error ,
44
- {
45
- message : 'Unexpected SGML declaration' ,
46
- name : '1:10' ,
47
- reason : 'Unexpected SGML declaration' ,
48
- line : 1 ,
49
- column : 10 ,
50
- location : {
51
- start : { line : 1 , column : 10 , offset : 9 } ,
52
- end : { line : null , column : null }
53
- } ,
54
- source : 'xast-util-from-xml' ,
55
- ruleId : 'unexpected-sgml'
56
- } ,
30
+ t . deepLooseEqual (
31
+ String ( error ) ,
32
+ '1:10: Unexpected SGML declaration' ,
57
33
'should throw for SGML directives'
58
34
)
59
35
}
@@ -62,21 +38,9 @@ test('xast-util-from-xml', function(t) {
62
38
fromXml ( '<root>&foo;</root>' )
63
39
t . fail ( 'should fail (3)' )
64
40
} catch ( error ) {
65
- t . deepEqual (
66
- error ,
67
- {
68
- message : 'Invalid character entity' ,
69
- name : '1:12' ,
70
- reason : 'Invalid character entity' ,
71
- line : 1 ,
72
- column : 12 ,
73
- location : {
74
- start : { line : 1 , column : 12 , offset : 11 } ,
75
- end : { line : null , column : null }
76
- } ,
77
- source : 'xast-util-from-xml' ,
78
- ruleId : 'sax'
79
- } ,
41
+ t . deepLooseEqual (
42
+ String ( error ) ,
43
+ '1:12: Invalid character entity' ,
80
44
'should throw for unknown entities (1)'
81
45
)
82
46
}
@@ -85,21 +49,9 @@ test('xast-util-from-xml', function(t) {
85
49
fromXml ( '<root>©</root>' )
86
50
t . fail ( 'should fail (4)' )
87
51
} catch ( error ) {
88
- t . deepEqual (
89
- error ,
90
- {
91
- message : 'Invalid character entity' ,
92
- name : '1:13' ,
93
- reason : 'Invalid character entity' ,
94
- line : 1 ,
95
- column : 13 ,
96
- location : {
97
- start : { line : 1 , column : 13 , offset : 12 } ,
98
- end : { line : null , column : null }
99
- } ,
100
- source : 'xast-util-from-xml' ,
101
- ruleId : 'sax'
102
- } ,
52
+ t . deepLooseEqual (
53
+ String ( error ) ,
54
+ '1:13: Invalid character entity' ,
103
55
'should throw for unknown entities (2)'
104
56
)
105
57
}
@@ -108,155 +60,143 @@ test('xast-util-from-xml', function(t) {
108
60
fromXml ( '<root><a><b><c/></a></b></root>' )
109
61
t . fail ( 'should fail (5)' )
110
62
} catch ( error ) {
111
- t . deepEqual (
112
- error ,
113
- {
114
- message : 'Unexpected close tag' ,
115
- name : '1:21' ,
116
- reason : 'Unexpected close tag' ,
117
- line : 1 ,
118
- column : 21 ,
119
- location : {
120
- start : { line : 1 , column : 21 , offset : 20 } ,
121
- end : { line : null , column : null }
122
- } ,
123
- source : 'xast-util-from-xml' ,
124
- ruleId : 'sax'
125
- } ,
63
+ t . deepLooseEqual (
64
+ String ( error ) ,
65
+ '1:21: Unexpected close tag' ,
126
66
'should throw on invalid nesting'
127
67
)
128
68
}
129
69
130
70
t . throws (
131
- function ( ) {
71
+ function ( ) {
132
72
fromXml ( '<!doctype>' )
133
73
} ,
134
74
/ 1 : 1 1 : E x p e c t e d d o c t y p e n a m e / ,
135
75
'should throw on missing doctype name'
136
76
)
137
77
138
78
t . throws (
139
- function ( ) {
79
+ function ( ) {
140
80
fromXml ( '<!doctype !>' )
141
81
} ,
142
82
/ 1 : 1 3 : E x p e c t e d s t a r t o f d o c t y p e n a m e / ,
143
83
'should throw on invalid doctype name'
144
84
)
145
85
146
86
t . throws (
147
- function ( ) {
87
+ function ( ) {
148
88
fromXml ( '<!DOCTYPE name[<!ELEMENT greeting (#PCDATA)>]>' )
149
89
} ,
150
90
/ 1 : 4 7 : U n e x p e c t e d i n t e r n a l s u b s e t / ,
151
91
'should throw on internal subset directly after doctype name'
152
92
)
153
93
154
94
t . throws (
155
- function ( ) {
95
+ function ( ) {
156
96
fromXml ( '<!DOCTYPE name [<!ELEMENT greeting (#PCDATA)>]>' )
157
97
} ,
158
98
/ 1 : 4 8 : U n e x p e c t e d i n t e r n a l s u b s e t / ,
159
99
'should throw on internal subset after doctype name'
160
100
)
161
101
162
102
t . throws (
163
- function ( ) {
103
+ function ( ) {
164
104
fromXml ( '<!DOCTYPE name!>' )
165
105
} ,
166
106
/ 1 : 1 7 : E x p e c t e d d o c t y p e n a m e c h a r a c t e r , w h i t e s p a c e , o r d o c t y p e e n d / ,
167
107
'should throw on invalid character directly after doctype'
168
108
)
169
109
170
110
t . throws (
171
- function ( ) {
111
+ function ( ) {
172
112
fromXml ( '<!DOCTYPE name !>' )
173
113
} ,
174
114
/ 1 : 1 8 : E x p e c t e d e x t e r n a l i d e n t i f i e r \( ` P U B L I C ` o r ` S Y S T E M ` \) , w h i t e s p a c e , o r d o c t y p e e n d / ,
175
115
'should throw on invalid character after doctype'
176
116
)
177
117
178
118
t . throws (
179
- function ( ) {
119
+ function ( ) {
180
120
fromXml ( '<!DOCTYPE name PUB>' )
181
121
} ,
182
122
/ 1 : 2 0 : E x p e c t e d e x t e r n a l i d e n t i f i e r \( ` P U B L I C ` o r ` S Y S T E M ` \) / ,
183
123
'should throw on invalid external identifier (1)'
184
124
)
185
125
186
126
t . throws (
187
- function ( ) {
127
+ function ( ) {
188
128
fromXml ( '<!DOCTYPE name SYSTEm>' )
189
129
} ,
190
130
/ 1 : 2 3 : E x p e c t e d e x t e r n a l i d e n t i f i e r \( ` P U B L I C ` o r ` S Y S T E M ` \) / ,
191
131
'should throw on invalid external identifier (2)'
192
132
)
193
133
194
134
t . throws (
195
- function ( ) {
135
+ function ( ) {
196
136
fromXml ( '<!DOCTYPE name PUBLIC>' )
197
137
} ,
198
138
/ 1 : 2 3 : E x p e c t e d w h i t e s p a c e a f t e r ` P U B L I C ` / ,
199
139
'should throw on missing whitespace after public identifier'
200
140
)
201
141
202
142
t . throws (
203
- function ( ) {
143
+ function ( ) {
204
144
fromXml ( '<!DOCTYPE name PUBLIC !>' )
205
145
} ,
206
146
/ 1 : 2 5 : E x p e c t e d q u o t e o r a p o s t r o p h e t o s t a r t p u b l i c l i t e r a l / ,
207
147
'should throw on invalid character after public identifier'
208
148
)
209
149
210
150
t . throws (
211
- function ( ) {
151
+ function ( ) {
212
152
fromXml ( '<!DOCTYPE name PUBLIC "🤔">' )
213
153
} ,
214
154
/ 1 : 2 8 : E x p e c t e d p u b i d c h a r a c t e r i n p u b l i c l i t e r a l / ,
215
155
'should throw on invalid character in public identifier'
216
156
)
217
157
218
158
t . throws (
219
- function ( ) {
159
+ function ( ) {
220
160
fromXml ( '<!DOCTYPE name PUBLIC "literal"!>' )
221
161
} ,
222
162
/ 1 : 3 4 : E x p e c t e d w h i t e s p a c e a f t e r p u b l i c l i t e r a l / ,
223
163
'should throw on invalid character after public literal'
224
164
)
225
165
226
166
t . throws (
227
- function ( ) {
167
+ function ( ) {
228
168
fromXml ( '<!DOCTYPE name SYSTEM>' )
229
169
} ,
230
170
/ 1 : 2 3 : E x p e c t e d w h i t e s p a c e a f t e r ` S Y S T E M ` / ,
231
171
'should throw on missing whitespace after system identifier'
232
172
)
233
173
234
174
t . throws (
235
- function ( ) {
175
+ function ( ) {
236
176
fromXml ( '<!DOCTYPE name SYSTEM !>' )
237
177
} ,
238
178
/ 1 : 2 5 : E x p e c t e d q u o t e o r a p o s t r o p h e t o s t a r t s y s t e m l i t e r a l / ,
239
179
'should throw on invalid character after system identifier'
240
180
)
241
181
242
182
t . throws (
243
- function ( ) {
183
+ function ( ) {
244
184
fromXml ( '<!DOCTYPE name SYSTEM "asd>' )
245
185
} ,
246
186
/ 1 : 2 8 : U n e x p e c t e d e n d / ,
247
187
'should throw on unended system literal'
248
188
)
249
189
250
190
t . throws (
251
- function ( ) {
191
+ function ( ) {
252
192
fromXml ( '<!DOCTYPE name SYSTEM "asd" [<!ELEMENT greeting (#PCDATA)>]>' )
253
193
} ,
254
194
/ 1 : 6 1 : U n e x p e c t e d i n t e r n a l s u b s e t / ,
255
195
'should throw on internal subset after external id'
256
196
)
257
197
258
198
t . throws (
259
- function ( ) {
199
+ function ( ) {
260
200
fromXml ( '<!DOCTYPE name SYSTEM "asd" !>' )
261
201
} ,
262
202
/ 1 : 3 1 : E x p e c t e d w h i t e s p a c e o r e n d o f d o c t y p e / ,
@@ -266,12 +206,10 @@ test('xast-util-from-xml', function(t) {
266
206
t . end ( )
267
207
} )
268
208
269
- test ( 'fixtures' , function ( t ) {
209
+ test ( 'fixtures' , function ( t ) {
270
210
var base = join ( 'test' , 'fixtures' )
271
211
272
- fs . readdirSync ( base )
273
- . filter ( negate ( hidden ) )
274
- . forEach ( each )
212
+ fs . readdirSync ( base ) . filter ( negate ( hidden ) ) . forEach ( each )
275
213
276
214
t . end ( )
277
215
0 commit comments