@@ -9,28 +9,16 @@ var fromXml = require('..')
99
1010var join = path . join
1111
12- test ( 'xast-util-from-xml' , function ( t ) {
12+ test ( 'xast-util-from-xml' , function ( t ) {
1313 t . equal ( typeof fromXml , 'function' , 'should expose a function' )
1414
1515 try {
1616 fromXml ( '<root unquoted=attribute>' )
1717 t . fail ( 'should fail (1)' )
1818 } 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' ,
3422 'should throw messages'
3523 )
3624 }
@@ -39,21 +27,9 @@ test('xast-util-from-xml', function(t) {
3927 fromXml ( '<!ENTITY>' )
4028 t . fail ( 'should fail (2)' )
4129 } 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' ,
5733 'should throw for SGML directives'
5834 )
5935 }
@@ -62,21 +38,9 @@ test('xast-util-from-xml', function(t) {
6238 fromXml ( '<root>&foo;</root>' )
6339 t . fail ( 'should fail (3)' )
6440 } 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' ,
8044 'should throw for unknown entities (1)'
8145 )
8246 }
@@ -85,21 +49,9 @@ test('xast-util-from-xml', function(t) {
8549 fromXml ( '<root>©</root>' )
8650 t . fail ( 'should fail (4)' )
8751 } 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' ,
10355 'should throw for unknown entities (2)'
10456 )
10557 }
@@ -108,155 +60,143 @@ test('xast-util-from-xml', function(t) {
10860 fromXml ( '<root><a><b><c/></a></b></root>' )
10961 t . fail ( 'should fail (5)' )
11062 } 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' ,
12666 'should throw on invalid nesting'
12767 )
12868 }
12969
13070 t . throws (
131- function ( ) {
71+ function ( ) {
13272 fromXml ( '<!doctype>' )
13373 } ,
13474 / 1 : 1 1 : E x p e c t e d d o c t y p e n a m e / ,
13575 'should throw on missing doctype name'
13676 )
13777
13878 t . throws (
139- function ( ) {
79+ function ( ) {
14080 fromXml ( '<!doctype !>' )
14181 } ,
14282 / 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 / ,
14383 'should throw on invalid doctype name'
14484 )
14585
14686 t . throws (
147- function ( ) {
87+ function ( ) {
14888 fromXml ( '<!DOCTYPE name[<!ELEMENT greeting (#PCDATA)>]>' )
14989 } ,
15090 / 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 / ,
15191 'should throw on internal subset directly after doctype name'
15292 )
15393
15494 t . throws (
155- function ( ) {
95+ function ( ) {
15696 fromXml ( '<!DOCTYPE name [<!ELEMENT greeting (#PCDATA)>]>' )
15797 } ,
15898 / 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 / ,
15999 'should throw on internal subset after doctype name'
160100 )
161101
162102 t . throws (
163- function ( ) {
103+ function ( ) {
164104 fromXml ( '<!DOCTYPE name!>' )
165105 } ,
166106 / 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 / ,
167107 'should throw on invalid character directly after doctype'
168108 )
169109
170110 t . throws (
171- function ( ) {
111+ function ( ) {
172112 fromXml ( '<!DOCTYPE name !>' )
173113 } ,
174114 / 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 / ,
175115 'should throw on invalid character after doctype'
176116 )
177117
178118 t . throws (
179- function ( ) {
119+ function ( ) {
180120 fromXml ( '<!DOCTYPE name PUB>' )
181121 } ,
182122 / 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 ` \) / ,
183123 'should throw on invalid external identifier (1)'
184124 )
185125
186126 t . throws (
187- function ( ) {
127+ function ( ) {
188128 fromXml ( '<!DOCTYPE name SYSTEm>' )
189129 } ,
190130 / 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 ` \) / ,
191131 'should throw on invalid external identifier (2)'
192132 )
193133
194134 t . throws (
195- function ( ) {
135+ function ( ) {
196136 fromXml ( '<!DOCTYPE name PUBLIC>' )
197137 } ,
198138 / 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 ` / ,
199139 'should throw on missing whitespace after public identifier'
200140 )
201141
202142 t . throws (
203- function ( ) {
143+ function ( ) {
204144 fromXml ( '<!DOCTYPE name PUBLIC !>' )
205145 } ,
206146 / 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 / ,
207147 'should throw on invalid character after public identifier'
208148 )
209149
210150 t . throws (
211- function ( ) {
151+ function ( ) {
212152 fromXml ( '<!DOCTYPE name PUBLIC "🤔">' )
213153 } ,
214154 / 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 / ,
215155 'should throw on invalid character in public identifier'
216156 )
217157
218158 t . throws (
219- function ( ) {
159+ function ( ) {
220160 fromXml ( '<!DOCTYPE name PUBLIC "literal"!>' )
221161 } ,
222162 / 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 / ,
223163 'should throw on invalid character after public literal'
224164 )
225165
226166 t . throws (
227- function ( ) {
167+ function ( ) {
228168 fromXml ( '<!DOCTYPE name SYSTEM>' )
229169 } ,
230170 / 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 ` / ,
231171 'should throw on missing whitespace after system identifier'
232172 )
233173
234174 t . throws (
235- function ( ) {
175+ function ( ) {
236176 fromXml ( '<!DOCTYPE name SYSTEM !>' )
237177 } ,
238178 / 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 / ,
239179 'should throw on invalid character after system identifier'
240180 )
241181
242182 t . throws (
243- function ( ) {
183+ function ( ) {
244184 fromXml ( '<!DOCTYPE name SYSTEM "asd>' )
245185 } ,
246186 / 1 : 2 8 : U n e x p e c t e d e n d / ,
247187 'should throw on unended system literal'
248188 )
249189
250190 t . throws (
251- function ( ) {
191+ function ( ) {
252192 fromXml ( '<!DOCTYPE name SYSTEM "asd" [<!ELEMENT greeting (#PCDATA)>]>' )
253193 } ,
254194 / 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 / ,
255195 'should throw on internal subset after external id'
256196 )
257197
258198 t . throws (
259- function ( ) {
199+ function ( ) {
260200 fromXml ( '<!DOCTYPE name SYSTEM "asd" !>' )
261201 } ,
262202 / 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) {
266206 t . end ( )
267207} )
268208
269- test ( 'fixtures' , function ( t ) {
209+ test ( 'fixtures' , function ( t ) {
270210 var base = join ( 'test' , 'fixtures' )
271211
272- fs . readdirSync ( base )
273- . filter ( negate ( hidden ) )
274- . forEach ( each )
212+ fs . readdirSync ( base ) . filter ( negate ( hidden ) ) . forEach ( each )
275213
276214 t . end ( )
277215
0 commit comments