From ed14c7509c004deb1568ac04ad6d08c5cd8b6702 Mon Sep 17 00:00:00 2001 From: amit kumar gupta Date: Sun, 30 Jul 2023 07:57:56 +0530 Subject: [PATCH] Add test for last fix for builder # Conflicts: # spec/j2x_spec.js --- spec/j2x_spec.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/j2x_spec.js b/spec/j2x_spec.js index 2ab00f54..3ec7722e 100644 --- a/spec/j2x_spec.js +++ b/spec/j2x_spec.js @@ -482,6 +482,34 @@ describe("XMLBuilder", function() { const expected = `12`; 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 = `10061001`; + + 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 = { @@ -596,4 +624,5 @@ describe("XMLBuilder", function() { expect(result).toEqual(expected); }); + });