Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
4ac7862d
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看板
未验证
提交
4ac7862d
编写于
6月 19, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 19, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8646 增加 textencode 和 url模块相关可选参传undefined的用例
Merge pull request !8646 from 王犇/master
上级
c3c5cdee
25af6cf4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
133 addition
and
0 deletion
+133
-0
commonlibrary/ets_utils/url_lib_standard/src/main/js/test/url.test.js
...y/ets_utils/url_lib_standard/src/main/js/test/url.test.js
+96
-0
commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js
...ets_utils/util_lib_standard/src/main/js/test/util.test.js
+37
-0
未找到文件。
commonlibrary/ets_utils/url_lib_standard/src/main/js/test/url.test.js
浏览文件 @
4ac7862d
...
...
@@ -206,6 +206,19 @@ describe('UrlFunTest', function () {
expect
(
err
.
message
).
assertEqual
(
`Parameter error.The type of 4 must be string`
);
}
})
/**
* @tc.name: testNewURLParams001
* @tc.desc: The input parameter for New URLParams is undefined or null.
*/
it
(
'
testNewURLParams001
'
,
0
,
function
()
{
let
params
=
new
Url
.
URLParams
(
undefined
);
let
result
=
params
.
toString
();
expect
(
result
).
assertEqual
(
'
undefined=undefined
'
);
let
params1
=
new
Url
.
URLParams
(
null
);
let
result1
=
params1
.
toString
();
expect
(
result1
).
assertEqual
(
'
undefined=undefined
'
);
})
/**
* @tc.name: testParamsEntries001
...
...
@@ -488,6 +501,27 @@ describe('UrlFunTest', function () {
}
})
/**
* @tc.name: testParamsForEach007
* @tc.desc: The second parameter of forEach is undefined or null.
*/
it
(
'
testParamsForEach007
'
,
0
,
function
()
{
let
params
=
new
Url
.
URLParams
(
"
key1=value1&key2=value2
"
)
var
arr
=
{};
var
i
=
0
;
function
func
(
value
,
key
,
SearchParams
)
{
arr
[
i
]
=
value
+
"
"
+
key
+
"
"
+
(
params
===
SearchParams
)
i
++
}
params
.
forEach
(
func
,
undefined
);
expect
(
arr
[
0
]).
assertEqual
(
"
value1 key1 true
"
);
arr
=
{};
i
=
0
;
params
.
forEach
(
func
,
null
);
expect
(
arr
[
0
]).
assertEqual
(
"
value1 key1 true
"
);
})
/**
* @tc.name: testParamsGet001
* @tc.desc: Returns the first value associated to the given search parameter.
...
...
@@ -1186,6 +1220,19 @@ describe('UrlFunTest', function () {
}
})
/**
* @tc.name: testNewURLSearchParams
* @tc.desc: The input parameter for New URLSearchParams is undefined or null.
*/
it
(
'
testNewURLSearchParams
'
,
0
,
function
()
{
let
params
=
new
Url
.
URLSearchParams
(
undefined
);
let
result
=
params
.
toString
()
expect
(
result
).
assertEqual
(
'
undefined=undefined
'
)
let
params1
=
new
Url
.
URLSearchParams
(
null
);
let
result2
=
params1
.
toString
()
expect
(
result2
).
assertEqual
(
'
undefined=undefined
'
)
})
/**
* @tc.name: testUrlAppend001
* @tc.desc: Appends a specified key/value pair as a new search parameter.
...
...
@@ -1585,6 +1632,27 @@ describe('UrlFunTest', function () {
expect
(
arr
[
0
]).
assertEqual
(
"
bar foo true
"
);
})
/**
* @tc.name: testUrlForEach006
* @tc.desc: The second parameter of forEach is undefined or null.
*/
it
(
'
testUrlForEach006
'
,
0
,
function
()
{
let
params
=
new
Url
.
URLSearchParams
(
"
key1=value1&key2=value2
"
)
var
arr
=
{};
var
i
=
0
;
function
func
(
value
,
key
,
SearchParams
)
{
arr
[
i
]
=
value
+
"
"
+
key
+
"
"
+
(
params
===
SearchParams
)
i
++
}
params
.
forEach
(
func
,
undefined
);
expect
(
arr
[
0
]).
assertEqual
(
"
value1 key1 true
"
);
arr
=
{}
i
=
0
;
params
.
forEach
(
func
,
null
);
expect
(
arr
[
0
]).
assertEqual
(
"
value1 key1 true
"
);
})
/**
* @tc.name: testUrlGet001
* @tc.desc: Returns the first value associated to the given search parameter.
...
...
@@ -2194,6 +2262,19 @@ describe('UrlFunTest', function () {
expect
(
paramsResult
).
assertEqual
(
'
abcde=fghki
'
)
})
/**
* @tc.name: testNewUrl001
* @tc.desc: The second parameter of Url construction is undefined or null.
*/
it
(
'
testNewUrl001
'
,
0
,
function
()
{
let
params
=
new
Url
.
URL
(
'
http://username:password@host:8080/directory/file?query#fragment
'
,
undefined
)
let
result
=
params
.
toString
()
expect
(
result
).
assertEqual
(
"
http://username:password@host:8080/directory/file?query#fragment
"
)
let
params1
=
new
Url
.
URL
(
'
http://username:password@host:8080/directory/file?query#fragment
'
,
null
)
let
result2
=
params1
.
toString
()
expect
(
result2
).
assertEqual
(
"
http://username:password@host:8080/directory/file?query#fragment
"
)
})
/**
* @tc.name: testUrlToString001
* @tc.desc: Returns the serialized URL as a string.
...
...
@@ -3326,4 +3407,19 @@ describe('UrlFunTest', function () {
expect
(
err
.
message
).
assertEqual
(
`Syntax Error. Invalid Url string`
);
}
})
/**
* @tc.name: testUrlparseURL011
* @tc.desc: The second parameter of parseURL is undefined or null.
*/
it
(
'
testUrlparseURL011
'
,
0
,
function
()
{
let
params
=
new
Url
.
URL
()
expect
(
params
!=
null
).
assertTrue
()
let
params1
=
Url
.
URL
.
parseURL
(
'
https://developer.mozilla.org
'
,
undefined
)
let
result
=
params1
.
href
expect
(
result
).
assertEqual
(
'
https://developer.mozilla.org/
'
)
let
params2
=
Url
.
URL
.
parseURL
(
'
https://developer.mozilla.org
'
,
null
)
let
result1
=
params2
.
href
expect
(
result1
).
assertEqual
(
'
https://developer.mozilla.org/
'
)
})
})}
\ No newline at end of file
commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js
浏览文件 @
4ac7862d
...
...
@@ -1102,6 +1102,19 @@ describe('TextEncoderTest', function () {
expect
(
str
).
assertEqual
(
'
GB2312
'
)
})
/**
* @tc.name: testencoding_textencoder_005
* @tc.desc: The TextEncoder construction parameter is undefined or null.
*/
it
(
'
testencoding_textencoder_005
'
,
0
,
function
()
{
let
encode1
=
new
util
.
TextEncoder
(
undefined
)
let
str1
=
encode1
.
encoding
expect
(
str1
).
assertEqual
(
'
utf-8
'
)
let
encode2
=
new
util
.
TextEncoder
(
null
)
let
str2
=
encode2
.
encoding
expect
(
str2
).
assertEqual
(
'
utf-8
'
)
})
/**
* @tc.name: testEncode001
* @tc.desc: Returns the result of encoder.
...
...
@@ -1311,6 +1324,18 @@ describe('TextEncoderTest', function () {
expect
(
result
[
119
]).
assertEqual
(
254
)
})
/**
* @tc.name: testEncode016
* @tc.desc: The encode parameter is undefined or null.
*/
it
(
'
testEncode016
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
()
let
result1
=
that
.
encode
(
undefined
)
expect
(
result1
).
assertEqual
(
undefined
)
let
result2
=
that
.
encode
(
null
)
expect
(
result2
).
assertEqual
(
undefined
)
})
/**
* @tc.name: testEncodeInto001
* @tc.desc: encode string, write the result to dest array.
...
...
@@ -1422,6 +1447,18 @@ describe('TextEncoderTest', function () {
expect
(
result
.
read
).
assertEqual
(
0
)
expect
(
result
.
written
).
assertEqual
(
0
)
})
/**
* @tc.name: testEncodeInto001
* @tc.desc: The encodeInto parameter is undefined or null
*/
it
(
'
testEncodeInto009
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
()
let
result1
=
that
.
encodeInto
(
undefined
)
expect
(
result1
).
assertEqual
(
undefined
)
let
result2
=
that
.
encodeInto
(
null
)
expect
(
result2
).
assertEqual
(
undefined
)
})
})
describe
(
'
ScopeTest
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录