-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add verbose output option. Fixes #30
- Loading branch information
Showing
7 changed files
with
304 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import $$ from "../TestHelpers"; | ||
|
||
describe("Replicate issue", () => { | ||
// https://github.com/oozcitak/xmlbuilder2/issues/30 | ||
test("#30 - Conversion from XML to JSON array inconsistency", () => { | ||
const input2 = $$.t` | ||
<data> | ||
<row id="0"> | ||
<TYPE>X</TYPE> | ||
<ID>123</ID> | ||
</row> | ||
<row id="1"> | ||
<TYPE>Y</TYPE> | ||
<ID>321</ID> | ||
</row> | ||
</data>` | ||
|
||
const obj2 = $$.convert(input2, { format: 'object', verbose: true }) | ||
expect(obj2).toEqual( | ||
{ | ||
"data": [ | ||
{ | ||
"row": [ | ||
{ | ||
"@id": "0", | ||
"TYPE": [ "X" ], | ||
"ID": [ "123" ] | ||
}, | ||
{ | ||
"@id": "1", | ||
"TYPE": [ "Y" ], | ||
"ID": [ "321" ] | ||
} | ||
] | ||
} | ||
] | ||
}) | ||
expect($$.create(obj2).end({ headless: true, prettyPrint: true })).toBe(input2) | ||
|
||
const input1 = $$.t` | ||
<data> | ||
<row id="0"> | ||
<TYPE>X</TYPE> | ||
<ID>123</ID> | ||
</row> | ||
</data>` | ||
const obj1 = $$.convert(input1, { format: 'object', verbose: true }) | ||
expect(obj1).toEqual( | ||
{ | ||
"data": [ | ||
{ | ||
"row": [ | ||
{ | ||
"@id": "0", | ||
"TYPE": [ "X" ], | ||
"ID": [ "123" ] | ||
} | ||
] | ||
} | ||
] | ||
}) | ||
expect($$.create(obj1).end({ headless: true, prettyPrint: true })).toBe(input1) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.