Skip to content

Commit

Permalink
Add test for last fix for builder
Browse files Browse the repository at this point in the history
# Conflicts:
#	spec/j2x_spec.js
  • Loading branch information
amitguptagwl committed Jul 30, 2023
1 parent df7008f commit ed14c75
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/j2x_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,34 @@ describe("XMLBuilder", function() {
const expected = `<a><b>1</b><b>2</b></a>`;
expect(result).toEqual(expected);
});

it('should build tag with only text node', async () => {
const schema_obj = {
field: {
values: {
value: {
'#text': 10061001,
size: '5',
},
},
id: 'skuCombineContent',
name: 'skuProduct',
type: 'multiInput',
},
};

const parse_options = {
ignoreAttributes: false,
attributeNamePrefix: '',
textNodeName: '#text',
};
const expected = `<field id="skuCombineContent" name="skuProduct" type="multiInput"><values><value size="5">10061001</value></values></field>`;

const builder = new XMLBuilder(parse_options);
const schema_xml = builder.build(schema_obj);
// console.log(schema_xml);
expect(schema_xml).toEqual(expected);
});

it("should suppress null attributes in the xml when format is true and ignoreAttributes is false", function () {
const jObj = {
Expand Down Expand Up @@ -596,4 +624,5 @@ describe("XMLBuilder", function() {

expect(result).toEqual(expected);
});

});

0 comments on commit ed14c75

Please sign in to comment.