11"use strict" ;
22
3- import { XMLParser , XMLValidator } from "../src/fxp.js" ;
4- // import he from "he";
3+ import { XMLParser , XMLValidator } from "../src/fxp.js" ;
54
6- describe ( "XMLParser" , function ( ) {
7-
8- it ( "should parse attributes having '>' in value" , function ( ) {
5+ describe ( "XMLParser" , function ( ) {
6+
7+ it ( "should parse attributes having '>' in value" , function ( ) {
98 const xmlData = `
109 <testStep type="restrequest" name="test step name (bankId -> Error)" id="90e453d3-30cd-4958-a3be-61ecfe7a7cbe">
1110 <settings/>
@@ -15,16 +14,16 @@ describe("XMLParser", function() {
1514 const expected = {
1615 "testStep" : {
1716 "type" : "restrequest" ,
18- "name" : "test step name (bankId -> Error)" ,
19- "id" : "90e453d3-30cd-4958-a3be-61ecfe7a7cbe" ,
17+ "name" : "test step name (bankId -> Error)" ,
18+ "id" : "90e453d3-30cd-4958-a3be-61ecfe7a7cbe" ,
2019 "settings" : "" ,
2120 "encoding" : "UTF-8"
2221 }
2322 } ;
2423
2524 const options = {
2625 attributeNamePrefix : "" ,
27- ignoreAttributes : false ,
26+ ignoreAttributes : false ,
2827 } ;
2928 const parser = new XMLParser ( options ) ;
3029 let result = parser . parse ( xmlData ) ;
@@ -36,7 +35,7 @@ describe("XMLParser", function() {
3635 expect ( result ) . toBe ( true ) ;
3736 } ) ;
3837
39- it ( "should parse attributes with valid names" , function ( ) {
38+ it ( "should parse attributes with valid names" , function ( ) {
4039 const xmlData = `
4140 <a>
4241 <bug atr="sasa" boolean>val
@@ -68,16 +67,16 @@ describe("XMLParser", function() {
6867
6968 const options = {
7069 allowBooleanAttributes : true ,
71- ignoreAttributes : false ,
70+ ignoreAttributes : false ,
7271 } ;
7372 const parser = new XMLParser ( options ) ;
7473 let result = parser . parse ( xmlData ) ;
7574
7675 // console.log(JSON.stringify(result,null,4));
7776 expect ( result ) . toEqual ( expected ) ;
7877 } ) ;
79-
80- it ( "should parse attributes with valid names" , function ( ) {
78+
79+ it ( "should parse attributes with valid names" , function ( ) {
8180 const xmlData = `<a:root xmlns:a="urn:none" xmlns:a-b="urn:none">
8281 <a:a attr="2foo&bar'">1</a:a>
8382 <a:b>2</a:b>
@@ -112,7 +111,7 @@ describe("XMLParser", function() {
112111
113112 const options = {
114113 allowBooleanAttributes : true ,
115- ignoreAttributes : false ,
114+ ignoreAttributes : false ,
116115 processEntities : false
117116 } ;
118117 const parser = new XMLParser ( options ) ;
@@ -121,8 +120,8 @@ describe("XMLParser", function() {
121120 //console.log(JSON.stringify(result,null,4));
122121 expect ( result ) . toEqual ( expected ) ;
123122 } ) ;
124-
125- it ( "should parse tagName without whitespace chars" , function ( ) {
123+
124+ it ( "should parse tagName without whitespace chars" , function ( ) {
126125 const xmlData = `<a:root
127126 attr='df'>val
128127 </a:root>` ;
@@ -136,7 +135,7 @@ describe("XMLParser", function() {
136135
137136 const options = {
138137 allowBooleanAttributes : true ,
139- ignoreAttributes : false ,
138+ ignoreAttributes : false ,
140139 } ;
141140 const parser = new XMLParser ( options ) ;
142141 let result = parser . parse ( xmlData , true ) ;
@@ -145,60 +144,60 @@ describe("XMLParser", function() {
145144 expect ( result ) . toEqual ( expected ) ;
146145 } ) ;
147146
148- it ( "should parse XML when namespaced ignored" , function ( ) {
147+ it ( "should parse XML when namespaced ignored" , function ( ) {
149148 const xmlData = `<root><a:b>c</a:b><a:d/><a:e atr="sasa" boolean></root>` ;
150149 const expected = {
151- "root" :{
152- "b" : "c" ,
153- "d" : "" ,
154- "e" : {
150+ "root" : {
151+ "b" : "c" ,
152+ "d" : "" ,
153+ "e" : {
155154 "@_atr" : "sasa" ,
156155 "@_boolean" : true ,
157156 }
158157 }
159158 } ;
160159
161160 const options = {
162- ignoreAttributes : false ,
161+ ignoreAttributes : false ,
163162 allowBooleanAttributes : true ,
164- removeNSPrefix : true ,
163+ removeNSPrefix : true ,
165164 } ;
166165
167166 const parser = new XMLParser ( options ) ;
168167 let result = parser . parse ( xmlData ) ;
169-
168+
170169 // console.log(JSON.stringify(result,null,4));
171170 expect ( result ) . toEqual ( expected ) ;
172171 } ) ;
173172
174- it ( "should parse XML with undefined as text" , function ( ) {
173+ it ( "should parse XML with undefined as text" , function ( ) {
175174 const xmlData = `<tag><![CDATA[undefined]]><nested>undefined</nested></tag>` ;
176175 const expected = {
177- "tag" : {
176+ "tag" : {
178177 "#text" : "undefined" ,
179178 "nested" : "undefined"
180179 }
181180 } ;
182181
183182 const options = {
184183 allowBooleanAttributes : true ,
185- ignoreAttributes : false ,
184+ ignoreAttributes : false ,
186185 } ;
187186 const parser = new XMLParser ( options ) ;
188187 let result = parser . parse ( xmlData , true ) ;
189188
190189 expect ( result ) . toEqual ( expected ) ;
191190 } ) ;
192191
193- it ( "should trim \t or \n chars" , function ( ) {
192+ it ( "should trim \t or \n chars" , function ( ) {
194193 const xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
195- "<MPD\n" +
196- "\tavailabilityStartTime=\"2020-02-16T10:52:03.119Z\"\n" +
197- "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
198- "\t<Period\n" +
199- "\t\tid=\"1578477220\">\n" +
200- "\t</Period>\n" +
201- "</MPD>" ;
194+ "<MPD\n" +
195+ "\tavailabilityStartTime=\"2020-02-16T10:52:03.119Z\"\n" +
196+ "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
197+ "\t<Period\n" +
198+ "\t\tid=\"1578477220\">\n" +
199+ "\t</Period>\n" +
200+ "</MPD>" ;
202201 const expected = {
203202 "?xml" : {
204203 "$" : {
@@ -208,8 +207,8 @@ describe("XMLParser", function() {
208207 } ,
209208 "MPD" : {
210209 "$" : {
211- "availabilityStartTime" : "2020-02-16T10:52:03.119Z" ,
212- "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance"
210+ "availabilityStartTime" : "2020-02-16T10:52:03.119Z" ,
211+ "xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance"
213212 } ,
214213 "Period" : {
215214 "$" : {
@@ -219,61 +218,61 @@ describe("XMLParser", function() {
219218 }
220219 }
221220
222- const options = {
223- ignoreAttributes : false ,
221+ const options = {
222+ ignoreAttributes : false ,
224223 allowBooleanAttributes : true ,
225- attributesGroupName :"$" ,
226- attributeNamePrefix : "" //TODO attr node prefix should not set when they're grouped
224+ attributesGroupName : "$" ,
225+ attributeNamePrefix : "" //TODO attr node prefix should not set when they're grouped
227226 } ;
228227 const parser = new XMLParser ( options ) ;
229228 let result = parser . parse ( xmlData ) ;
230229 // console.log(JSON.stringify(result,null,4));
231230 expect ( result ) . toEqual ( expected ) ;
232231 } ) ;
233232
234- it ( "should error for when any tag is left to close" , function ( ) {
233+ it ( "should error for when any tag is left to close" , function ( ) {
235234 const xmlData = `<?xml version="1.0"?><tag></tag` ;
236- expect ( ( ) => {
235+ expect ( ( ) => {
237236 const parser = new XMLParser ( ) ;
238237 parser . parse ( xmlData ) ;
239-
238+
240239 } ) . toThrowError ( "Closing Tag is not closed." )
241240 } )
242- it ( "should error for when any tag is left to close" , function ( ) {
241+ it ( "should error for when any tag is left to close" , function ( ) {
243242 const xmlData = `<?xml version="1.0"?><!-- bad ` ;
244- expect ( ( ) => {
243+ expect ( ( ) => {
245244 const parser = new XMLParser ( ) ;
246245 parser . parse ( xmlData ) ;
247246 } ) . toThrowError ( "Comment is not closed." )
248247 } )
249- it ( "should error for when any tag is left to close" , function ( ) {
248+ it ( "should error for when any tag is left to close" , function ( ) {
250249 const xmlData = `<?xml version="1.0"?><![CDATA ]` ;
251- expect ( ( ) => {
250+ expect ( ( ) => {
252251 const parser = new XMLParser ( ) ;
253252 parser . parse ( xmlData ) ;
254253 } ) . toThrowError ( "CDATA is not closed." )
255254 } )
256255
257- it ( "should error for when any tag is left to close" , function ( ) {
256+ it ( "should error for when any tag is left to close" , function ( ) {
258257 const xmlData = `<?xml version="1.0"?><?pi ` ;
259- expect ( ( ) => {
258+ expect ( ( ) => {
260259 const parser = new XMLParser ( ) ;
261260 parser . parse ( xmlData ) ;
262261 } ) . toThrowError ( "Pi Tag is not closed." )
263262 } )
264-
265- it ( "should parse XML when there is a space after tagname" , function ( ) {
263+
264+ it ( "should parse XML when there is a space after tagname" , function ( ) {
266265 const xmlData = `<tag ><![CDATA[undefined]]><nested>undefined</nested></tag>` ;
267266 const expected = {
268- "tag" : {
267+ "tag" : {
269268 "#text" : "undefined" ,
270269 "nested" : "undefined"
271270 }
272271 } ;
273272
274273 const options = {
275274 allowBooleanAttributes : true ,
276- ignoreAttributes : false ,
275+ ignoreAttributes : false ,
277276 // processEntities: false
278277 } ;
279278 const parser = new XMLParser ( options ) ;
0 commit comments