diff --git a/commonlibrary/ets_utils/convertxml_lib_standard/src/main/js/test/convertxml.test.js b/commonlibrary/ets_utils/convertxml_lib_standard/src/main/js/test/convertxml.test.js index e66c95cf6f87985a9e2bcdbf78755f04548a19a5..f92a5a3cd753abe952f87e87552ba07c800f9840 100644 --- a/commonlibrary/ets_utils/convertxml_lib_standard/src/main/js/test/convertxml.test.js +++ b/commonlibrary/ets_utils/convertxml_lib_standard/src/main/js/test/convertxml.test.js @@ -977,20 +977,17 @@ describe('XmlTest', function () { * @tc.desc: To convert XML text to JavaScript object. */ it('testConvert028', 0, function () { - let xml = ' \t ]]>'; + let xml = '\r\n \t ]]>'; let conv = new convertxml.ConvertXML(); let options = {trim : false, declarationKey:"_declaration", instructionKey : "_instruction", attributesKey : "_attributes", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", commentKey : "_comment", parentKey : "_parent", typeKey : "_type", nameKey : "_name", elementsKey : "_elements"} - let result = JSON.stringify(conv.convert(xml, options)); - let str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ - ' \\t'+ - ' '+ - '\\t '+ - '"}]}' - expect(result).assertEqual(str1); + let result = conv.convertToJSObject(xml, options); + let cdata = result._elements[0]._cdata; + let str1 = ' \\t \\r\\n \\t '; + expect(cdata).assertEqual(str1); }) /** @@ -998,26 +995,17 @@ describe('XmlTest', function () { * @tc.desc: To convert XML text to JavaScript object. */ it('testConvert029', 0, function () { - let xml = ' " and & \t ]]>'; + let xml = ' " and & \t ]]>'; let conv = new convertxml.ConvertXML(); let options = {trim : false, declarationKey:"_declaration", instructionKey : "_instruction", attributesKey : "_attributes", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", commentKey : "_comment", parentKey : "_parent", typeKey : "_type", nameKey : "_name", elementsKey : "_elements"} - let result = JSON.stringify(conv.convert(xml, options)); - console.log("LHC..." + result); - let str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ - ' \\t'+ - ' data"},{"_type":"cdata","_cdata":"< '+ - '> '+ - '\\"'+ - ' and'+ - ' & '+ - '\\t '+ - '"}]}'; - console.log("LHC..." + str1); - expect(result).assertEqual(str1); + let result = conv.convertToJSObject(xml, options); + let cdata = result._elements[0]._cdata; + let str = ' \\t data\\n< > \" and & \\t '; + expect(cdata).assertEqual(str); }) /**