-
-
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.
Do not group attributes in element content. Fixes #29
- Loading branch information
Showing
3 changed files
with
100 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import $$ from "../TestHelpers"; | ||
|
||
describe("Replicate issue", () => { | ||
// https://github.com/oozcitak/xmlbuilder2/issues/29 | ||
test("#29 - Attribute is a node", () => { | ||
const input = $$.t` | ||
<resources> | ||
<string name="countdown"> | ||
<xliff:g id="count" example="2 days">%1$s</xliff:g> | ||
until holiday | ||
<xliff:g id="time" example="5 days">%1$s</xliff:g> | ||
anything | ||
</string> | ||
</resources>` | ||
|
||
// test with default converter | ||
expect($$.convert(input, { format: 'object' })).toEqual( | ||
{ | ||
resources: { | ||
string: { | ||
'@name': 'countdown', | ||
'#': [ | ||
{ | ||
'xliff:g': { | ||
'@id': 'count', | ||
'@example': '2 days', | ||
'#': '%1$s' | ||
} | ||
}, | ||
{ '#': '\n until holiday\n ' }, | ||
{ | ||
'xliff:g': { | ||
'@id': 'time', | ||
'@example': '5 days', | ||
'#': '%1$s' | ||
} | ||
}, | ||
{ '#': '\n anything\n ' }, | ||
] | ||
} | ||
} | ||
} | ||
) | ||
|
||
// test with custom converter | ||
const obj = $$.convert({ encoding: 'UTF-8', convert: { text: 'value' } }, input, { format: 'object' }) | ||
|
||
expect(obj).toEqual( | ||
{ | ||
resources: { | ||
string: { | ||
'@name': 'countdown', | ||
value: [ | ||
{ | ||
'xliff:g': { | ||
'@id': 'count', | ||
'@example': '2 days', | ||
value: '%1$s' | ||
} | ||
}, | ||
{ value: '\n until holiday\n ' }, | ||
{ | ||
'xliff:g': { | ||
'@id': 'time', | ||
'@example': '5 days', | ||
value: '%1$s' | ||
} | ||
}, | ||
{ value: '\n anything\n ' }, | ||
] | ||
} | ||
} | ||
} | ||
) | ||
}) | ||
|
||
}) |
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