Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c9230af4
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c9230af4
编写于
4月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2968 Fix bug convertxml cannot work for release branch
Merge pull request !2968 from hunili/OpenHarmony-3.1-Release
上级
376e1154
bcd0236d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
392 addition
and
242 deletion
+392
-242
compileruntime/convertxml_lib_standard/src/main/js/test/convertxml.test.js
...nvertxml_lib_standard/src/main/js/test/convertxml.test.js
+392
-242
未找到文件。
compileruntime/convertxml_lib_standard/src/main/js/test/convertxml.test.js
浏览文件 @
c9230af4
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
ConvertXML
from
'
@ohos.convertxml
'
import
convertxml
from
'
@ohos.convertxml
'
describe
(
'
XmlTest
'
,
function
()
{
/**
...
...
@@ -30,8 +30,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
spaces
:
0
})
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -50,7 +55,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -67,8 +72,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
trim
:
true
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -87,7 +97,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -104,8 +114,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreDeclaration
:
true
});
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
ignoreDeclaration
:
true
,
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":"element",
'
+
'
"_name":"note",
'
+
'
"_attributes":{"importance":"high",
'
+
...
...
@@ -122,7 +137,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -140,8 +155,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreInstruction
:
true
});
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
ignoreInstruction
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -161,7 +181,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -178,8 +198,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreAttributes
:
true
});
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
ignoreAttributes
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -196,7 +221,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -214,8 +239,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreComment
:
true
})
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
ignoreComment
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -234,7 +264,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -252,8 +282,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreComment
:
true
})
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
ignoreComment
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -272,7 +307,7 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
...
...
@@ -290,8 +325,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreCDATA
:
true
})
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
ignoreCDATA
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -310,63 +350,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert0
0
9
* @tc.name: testConvert09
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert009
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
'
<title>Happy</title>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
spaces
:
4
})
let
str
=
'
{
\n
'
+
'
"_declaration": {
\n
'
+
'
"_attributes": {
\n
'
+
'
"version": "1.0",
\n
'
+
'
"encoding": "utf-8"
\n
'
+
'
}
\n
'
+
'
},
\n
'
+
'
"_elements": [
\n
'
+
'
{
\n
'
+
'
"_type": "element",
\n
'
+
'
"_name": "note",
\n
'
+
'
"_attributes": {
\n
'
+
'
"importance": "high",
\n
'
+
'
"logged": "true"
\n
'
+
'
},
\n
'
+
'
"_elements": [
\n
'
+
'
{
\n
'
+
'
"_type": "element",
\n
'
+
'
"_name": "title",
\n
'
+
'
"_elements": [
\n
'
+
'
{
\n
'
+
'
"_type": "text",
\n
'
+
'
"_text": "Happy"
\n
'
+
'
}
\n
'
+
'
]
\n
'
+
'
}
\n
'
+
'
]
\n
'
+
'
}
\n
'
+
'
]
\n
'
+
'
}
'
expect
(
result1
).
assertEqual
(
str
);
})
/**
* @tc.name: testConvert010
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert010
'
,
0
,
function
()
{
it
(
'
testConvert09
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!DOCTYPE foo>
'
+
...
...
@@ -375,8 +368,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreDoctype
:
true
})
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
declarationKey
:
"
_declaration
"
,
ignoreDoctype
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -395,16 +393,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
1
* @tc.name: testConvert01
0
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
1
'
,
0
,
function
()
{
it
(
'
testConvert01
0
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -412,8 +410,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
ignoreText
:
true
})
let
conv
=
new
convertxml
.
ConvertXML
();
let
options
=
{
trim
:
false
,
ignoreText
:
true
,
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -426,16 +429,16 @@ describe('XmlTest', function () {
'
"_name":"todo"},
'
+
'
{"_type":"element",
'
+
'
"_name":"todo"}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
2
* @tc.name: testConvert01
1
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
2
'
,
0
,
function
()
{
it
(
'
testConvert01
1
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -443,8 +446,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
declarationKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"123":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -463,16 +471,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
3
* @tc.name: testConvert01
2
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
3
'
,
0
,
function
()
{
it
(
'
testConvert01
2
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -481,8 +489,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
instructionKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -504,16 +517,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
4
* @tc.name: testConvert01
3
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
4
'
,
0
,
function
()
{
it
(
'
testConvert01
3
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -522,8 +535,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
attributesKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"123":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"123":{"importance":"high",
'
+
...
...
@@ -545,16 +563,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
5
* @tc.name: testConvert01
4
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
5
'
,
0
,
function
()
{
it
(
'
testConvert01
4
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -562,8 +580,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
textKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -582,16 +605,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"123":"Play",
'
+
'
"_type":"text"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
6
* @tc.name: testConvert01
5
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
6
'
,
0
,
function
()
{
it
(
'
testConvert01
5
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -600,8 +623,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
cdataKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -622,16 +650,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
7
* @tc.name: testConvert01
6
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
7
'
,
0
,
function
()
{
it
(
'
testConvert01
6
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!--note-->
'
+
...
...
@@ -640,8 +668,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
commentKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"123":"note",
'
+
...
...
@@ -662,16 +695,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
8
* @tc.name: testConvert01
7
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
8
'
,
0
,
function
()
{
it
(
'
testConvert01
7
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -680,8 +713,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
parentKey
:
"
123
"
})
let
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
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"element",
'
+
...
...
@@ -704,16 +742,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert01
9
* @tc.name: testConvert01
8
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert01
9
'
,
0
,
function
()
{
it
(
'
testConvert01
8
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -721,8 +759,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
typeKey
:
"
123
"
})
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
:
"
123
"
,
nameKey
:
"
_name
"
,
elementsKey
:
"
_elements
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"123":"element",
'
+
...
...
@@ -741,16 +784,16 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"123":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert0
20
* @tc.name: testConvert0
19
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert0
20
'
,
0
,
function
()
{
it
(
'
testConvert0
19
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -758,8 +801,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
nameKey
:
"
123
"
})
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
:
"
123
"
,
elementsKey
:
"
_elements
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"123":"note",
'
+
...
...
@@ -778,16 +826,16 @@ describe('XmlTest', function () {
'
"_type":"element",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
1
* @tc.name: testConvert02
0
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
1
'
,
0
,
function
()
{
it
(
'
testConvert02
0
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<note importance="high" logged="true">
'
+
...
...
@@ -795,8 +843,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
elementsKey
:
"
123
"
})
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
:
"
123
"
}
let
result
=
JSON
.
stringify
(
conv
.
convert
(
xml
,
options
));
let
str1
=
'
{"123":[{"123":[{"123":[{"_type":"text",
'
+
'
"_text":"Happy"}],
'
+
'
"_type":"element",
'
+
...
...
@@ -815,329 +868,421 @@ describe('XmlTest', function () {
'
"logged":"true"}}],
'
+
'
"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}}}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
2
* @tc.name: testConvert02
1
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
2
'
,
0
,
function
()
{
it
(
'
testConvert02
1
'
,
0
,
function
()
{
let
xml
=
'
<?xml?>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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
=
'
{"_declaration":{}}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
3
* @tc.name: testConvert02
2
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
3
'
,
0
,
function
()
{
it
(
'
testConvert02
2
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}}}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
4
* @tc.name: testConvert02
3
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
4
'
,
0
,
function
()
{
it
(
'
testConvert02
3
'
,
0
,
function
()
{
let
xml
=
'
<?xml?>
\n
<a/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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
=
'
{"_declaration":{},"_elements":[{"_type":"element","_name":"a"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
5
* @tc.name: testConvert02
4
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
5
'
,
0
,
function
()
{
it
(
'
testConvert02
4
'
,
0
,
function
()
{
let
xml
=
'
<?go there?>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"instruction",
'
+
'
"_name":"go",
'
+
'
"_instruction":"there"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
6
* @tc.name: testConvert02
5
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
6
'
,
0
,
function
()
{
it
(
'
testConvert02
5
'
,
0
,
function
()
{
let
xml
=
'
<?go there?><?come here?>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"instruction",
'
+
'
"_name":"go",
'
+
'
"_instruction":"there"},
'
+
'
{"_type":"instruction",
'
+
'
"_name":"come",
'
+
'
"_instruction":"here"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
7
* @tc.name: testConvert02
6
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
7
'
,
0
,
function
()
{
it
(
'
testConvert02
6
'
,
0
,
function
()
{
let
xml
=
'
<!--
\t
Hello World!
\t
-->
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"comment","_comment":"
'
+
'
\t
'
+
'
\
\
t
'
+
'
Hello
'
+
'
World!
'
+
'
\t
'
+
'
\
\
t
'
+
'
"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
8
* @tc.name: testConvert02
7
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
8
'
,
0
,
function
()
{
it
(
'
testConvert02
7
'
,
0
,
function
()
{
let
xml
=
'
<!--
\t
Hello
\t
-->
\n
<!--
\t
World
\t
-->
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"comment","_comment":"
'
+
'
\t
'
+
'
\
\
t
'
+
'
Hello
'
+
'
\t
'
+
'
\
\
t
'
+
'
"},{"_type":"comment","_comment":"
'
+
'
\t
'
+
'
\
\
t
'
+
'
World
'
+
'
\t
'
+
'
\
\
t
'
+
'
"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert02
9
* @tc.name: testConvert02
8
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert02
9
'
,
0
,
function
()
{
it
(
'
testConvert02
8
'
,
0
,
function
()
{
let
xml
=
'
<![CDATA[
\t
<foo></bar>
\t
]]>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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
'
+
'
<foo></bar>
'
+
'
\t
'
+
'
\
\
t
'
+
'
"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert0
30
* @tc.name: testConvert0
29
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert0
30
'
,
0
,
function
()
{
it
(
'
testConvert0
29
'
,
0
,
function
()
{
let
xml
=
'
<![CDATA[
\t
data]]><![CDATA[< > " and &
\t
]]>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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
'
+
'
\
\
t
'
+
'
data"},{"_type":"cdata","_cdata":"<
'
+
'
>
'
+
'
"
'
+
'
\\
"
'
+
'
and
'
+
'
&
'
+
'
\t
'
+
'
"}]}
'
expect
(
result1
).
assertEqual
(
str1
);
'
\\
t
'
+
'
"}]}
'
;
console
.
log
(
"
LHC...
"
+
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
1
* @tc.name: testConvert03
0
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
1
'
,
0
,
function
()
{
it
(
'
testConvert03
0
'
,
0
,
function
()
{
let
xml
=
'
<a/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
2
* @tc.name: testConvert03
1
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
2
'
,
0
,
function
()
{
it
(
'
testConvert03
1
'
,
0
,
function
()
{
let
xml
=
'
<a/>
\n
<a/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a"},
'
+
'
{"_type":"element",
'
+
'
"_name":"a"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
3
* @tc.name: testConvert03
2
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
3
'
,
0
,
function
()
{
it
(
'
testConvert03
2
'
,
0
,
function
()
{
let
xml
=
'
<a/>
\n
<b/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a"},
'
+
'
{"_type":"element",
'
+
'
"_name":"b"}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
4
* @tc.name: testConvert03
3
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
4
'
,
0
,
function
()
{
it
(
'
testConvert03
3
'
,
0
,
function
()
{
let
xml
=
'
<a x="hello"/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a",
'
+
'
"_attributes":{"x":"hello"}}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
5
* @tc.name: testConvert03
4
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
5
'
,
0
,
function
()
{
it
(
'
testConvert03
4
'
,
0
,
function
()
{
let
xml
=
'
<a x="1.234" y="It
\'
s"/>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a",
'
+
'
"_attributes":{"x":"1.234",
'
+
'
"y":"It
\'
s"}}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
6
* @tc.name: testConvert03
5
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
6
'
,
0
,
function
()
{
it
(
'
testConvert03
5
'
,
0
,
function
()
{
let
xml
=
'
<a>
\t
Hi
\t
</a>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element","_name":"a","_elements":[{"_type":"text","_text":"
'
+
'
\t
'
+
'
\
\
t
'
+
'
Hi
'
+
'
\t
'
+
'
\
\
t
'
+
'
"}]}]}
'
;
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
7
* @tc.name: testConvert03
6
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
7
'
,
0
,
function
()
{
it
(
'
testConvert03
6
'
,
0
,
function
()
{
let
xml
=
'
<a> Hi There
\t
</a>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element","_name":"a","_elements":[{"_type":"text","_text":"
'
+
'
Hi
'
+
'
There
'
+
'
\t
'
+
'
\
\
t
'
+
'
"}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
8
* @tc.name: testConvert03
7
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
8
'
,
0
,
function
()
{
it
(
'
testConvert03
7
'
,
0
,
function
()
{
let
xml
=
'
<a>
\n\
v<b/>
\n
</a>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a",
'
+
'
"_elements":[{"_type":"element",
'
+
'
"_name":"b"}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert03
9
* @tc.name: testConvert03
8
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert03
9
'
,
0
,
function
()
{
it
(
'
testConvert03
8
'
,
0
,
function
()
{
let
xml
=
'
<a>
\n\
v<b>
\n\
v
\
v<c/>
\n\
v</b>
\n
</a>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
})
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":"element",
'
+
'
"_name":"a",
'
+
'
"_elements":[{"_type":"element",
'
+
'
"_name":"b",
'
+
'
"_elements":[{"_type":"element",
'
+
'
"_name":"c"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
assertEqual
(
str1
);
})
/**
* @tc.name: testConvert0
40
* @tc.name: testConvert0
39
* @tc.desc: To convert XML text to JavaScript object.
* @tc.require: AR000GFB5B
* @tc.author: lihucheng
*/
it
(
'
testConvert0
40
'
,
0
,
function
()
{
it
(
'
testConvert0
39
'
,
0
,
function
()
{
let
xml
=
'
<?xml version="1.0" encoding="utf-8"?>
'
+
'
<!DOCTYPE foo>
'
+
...
...
@@ -1146,8 +1291,13 @@ describe('XmlTest', function () {
'
<todo>Work</todo>
'
+
'
<todo>Play</todo>
'
+
'
</note>
'
;
let
convertml
=
new
ConvertXML
();
let
result1
=
convertml
.
convert
(
xml
,
{
compact
:
false
,
doctypeKey
:
'
doctype
'
})
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
=
'
{"_declaration":{"_attributes":{"version":"1.0",
'
+
'
"encoding":"utf-8"}},
'
+
'
"_elements":[{"_type":"doctype","doctype":"foo"},
'
+
...
...
@@ -1167,6 +1317,6 @@ describe('XmlTest', function () {
'
"_name":"todo",
'
+
'
"_elements":[{"_type":"text",
'
+
'
"_text":"Play"}]}]}]}
'
expect
(
result
1
).
assertEqual
(
str1
);
expect
(
result
).
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录