提交 ed607a35 编写于 作者: Z zhangfuzhi

deleted convertOptionsJsunit

Signed-off-by: Nzhangfuzhi <zhangfuzhi1@huawei.com>
上级 7507f211
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, expect, it } from '@ohos/hypium';
import convertxml from '@ohos.convertxml';
export default function convertOptionsJsunit() {
describe('XmlTest_radio_1', function () {
console.log("************* settings Test start*************");
it('Telephony_convertxml_ConvertXML_0100', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title> Happy </title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: true,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0300', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreAttributes: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <!--note-->' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreComment: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0600', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[<foo></bar>]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreCDATA: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0700', 0, async function (done) {
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 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",
ignoreDoctype: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0800', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreText: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title"},' +
'{"_type":"element",' +
'"_name":"todo"},' +
'{"_type":"element",' +
'"_name":"todo"}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_0900', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "123",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1000', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "123",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"there",' +
'"_type":"instruction",' +
'"_name":"go"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1100', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "123",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"123":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":{"importance":"high",' +
'"logged":"true"},' +
'"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"instruction",' +
'"_name":"go",' +
'"_instruction":"there"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "123",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"Happy",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"Work",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"Play",' +
'"_type":"text"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1300', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[1 is < 2]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "123",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"1 is < 2",' +
'"_type":"cdata"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1400', 0, async function (done) {
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 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"
};
var result1 = JSON.stringify(conv.convert(xml, options));
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);
console.info("Telephony_convertxml_ConvertXML_1400 result1 :"+result1);
done();
})
it('Telephony_convertxml_ConvertXML_1500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!--note-->' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "123",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"comment"},' +
'{"_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);
done();
})
it('Telephony_convertxml_ConvertXML_1600', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <a><b/></a>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "123",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"a",' +
'"_elements":[{"_type":"element",' +
'"_name":"b"}]},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1700', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"text",' +
'"_text":"Happy"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Work"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1800', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"element",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"title",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_1900', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' +
'"_text":"Happy"}],' +
'"_type":"element",' +
'"_name":"title"},' +
'{"123":[{"_type":"text",' +
'"_text":"Work"}],' +
'"_type":"element",' +
'"_name":"todo"},' +
'{"123":[{"_type":"text",' +
'"_text":"Play"}],' +
'"_type":"element",' +
'"_name":"todo"}],' +
'"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"}}],' +
'"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}}}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2000', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title> Happy </title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: true,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2100', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreDeclaration: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2300', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreAttributes: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <!--note-->' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreComment: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[<foo></bar>]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreCDATA: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2600', 0, async function (done) {
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 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",
ignoreDoctype: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2700', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreText: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title"},' +
'{"_type":"element",' +
'"_name":"todo"},' +
'{"_type":"element",' +
'"_name":"todo"}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2800', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "456",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"456":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_2900', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "456",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"456":"there",' +
'"_type":"instruction",' +
'"_name":"go"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3000', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "456",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"456":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"456":{"importance":"high",' +
'"logged":"true"},' +
'"_type":"element",' +
'"_name":"note",' +
'"_elements":[{"_type":"instruction",' +
'"_name":"go",' +
'"_instruction":"there"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3100', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "456",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"title",' +
'"_elements":[{"456":"Happy",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"456":"Work",' +
'"_type":"text"}]},' +
'{"_type":"element",' +
'"_name":"todo",' +
'"_elements":[{"456":"Play",' +
'"_type":"text"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3200', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <![CDATA[1 is < 2]]>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "456",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"456":"1 is < 2",' +
'"_type":"cdata"},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3300', 0, async function (done) {
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 conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "doctype_next",
commentKey: "_comment",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"doctype","doctype_next":"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);
done();
})
it('Telephony_convertxml_ConvertXML_3400', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!--note-->' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "456",
parentKey: "_parent",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"456":"note",' +
'"_type":"comment"},' +
'{"_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);
done();
})
it('Telephony_convertxml_ConvertXML_3500', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <a><b/></a>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var conv = new convertxml.ConvertXML();
let options = {
trim: false,
declarationKey: "_declaration",
instructionKey: "_instruction",
attributesKey: "_attributes",
textKey: "_text",
cdataKey: "_cdata",
doctypeKey: "_doctype",
commentKey: "_comment",
parentKey: "456",
typeKey: "_type",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"_type":"element",' +
'"_name":"a",' +
'"_elements":[{"_type":"element",' +
'"_name":"b"}]},' +
'{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3600', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123",
nameKey: "_name",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"element",' +
'"_name":"title",' +
'"_elements":[{"123":"text",' +
'"_text":"Happy"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Work"}]},' +
'{"123":"element",' +
'"_name":"todo",' +
'"_elements":[{"123":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3700', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123",
elementsKey: "_elements"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"123":"note",' +
'"_type":"element",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"},' +
'"_elements":[{"123":"title",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Happy"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Work"}]},' +
'{"123":"todo",' +
'"_type":"element",' +
'"_elements":[{"_type":"text",' +
'"_text":"Play"}]}]}]}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
it('Telephony_convertxml_ConvertXML_3800', 0, async function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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: "123"
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' +
'"_text":"Happy"}],' +
'"_type":"element",' +
'"_name":"title"},' +
'{"123":[{"_type":"text",' +
'"_text":"Work"}],' +
'"_type":"element",' +
'"_name":"todo"},' +
'{"123":[{"_type":"text",' +
'"_text":"Play"}],' +
'"_type":"element",' +
'"_name":"todo"}],' +
'"_type":"element",' +
'"_name":"note",' +
'"_attributes":{"importance":"high",' +
'"logged":"true"}}],' +
'"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}}}';
expect(result1).assertEqual(str1);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
/**
* @tc.name: Telephony_convertxml_ConvertXML_3900
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
*/
it('Telephony_convertxml_ConvertXML_3900', 0, function (done) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <?go there?>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var 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",
ignoreInstruction: true
};
var result1 = JSON.stringify(conv.convert(xml, options));
var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' +
'"encoding":"utf-8"}},' +
'"_elements":[{"_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);
expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1);
done();
})
})
}
\ No newline at end of file
/** /**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import convertOptionsJsunit from './ConvertOptionsJsunit.test';
import radioJsunit from './RadioJsunit.test'; import radioJsunit from './RadioJsunit.test';
import radioSecondJsunit from './RadioSecondJsunit.test'; import radioSecondJsunit from './RadioSecondJsunit.test';
import smsUiJsunit from './SmsMmsJsunit.test'; import smsUiJsunit from './SmsMmsJsunit.test';
...@@ -23,7 +23,6 @@ import dataJsunit from './DataJsunit.test'; ...@@ -23,7 +23,6 @@ import dataJsunit from './DataJsunit.test';
export default function testsuite() { export default function testsuite() {
dataJsunit(); dataJsunit();
smsUiJsunit(); smsUiJsunit();
convertOptionsJsunit();
radioJsunit(); radioJsunit();
radioSecondJsunit(); radioSecondJsunit();
callJsunit(); callJsunit();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册