提交 8ec77234 编写于 作者: X xdmal

Add a convertxml xts test case.

Signed-off-by: Nxdmal <maxiaodong16@huawei.com>
上级 d8795991
......@@ -1130,9 +1130,43 @@ describe('XmlTest', function () {
'"_name":"c"}]}]}]}'
expect(result1).assertEqual(str1);
})
})
/**
* @tc.name: testConvert040
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it('testConvert040', 0, function () {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE foo>'+
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var convertml = new ConvertXML();
var result1 = convertml.convert(xml, {compact: false, doctypeKey: 'doctype'})
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+
'"encoding":"utf-8"}},'+
'"_elements":[{"_type":"doctype","doctype":"foo"},'+
'{"_type":"element",'+
'"_name":"note",'+
'"_attributes":{"importance":"high",'+
'"logged":"true"},'+
'"_elements":[{"_type":"element",'+
'"_name":"title",'+
'"_elements":[{"_type":"text",'+
'"_text":"Happy"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Work"}]},'+
'{"_type":"element",'+
'"_name":"todo",'+
'"_elements":[{"_type":"text",'+
'"_text":"Play"}]}]}]}'
expect(result1).assertEqual(str1);
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册