Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9e765698
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看板
未验证
提交
9e765698
编写于
7月 21, 2023
作者:
高
高曦
提交者:
Gitee
7月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update Http.fetch.test.js.
Signed-off-by:
N
高曦
<
gaoxi785@huawei.com
>
上级
8e7a88eb
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
412 addition
and
313 deletion
+412
-313
telephony/telephonyjstest/netmanager_base/system_fetch/src/main/js/test/Http.fetch.test.js
...ger_base/system_fetch/src/main/js/test/Http.fetch.test.js
+412
-313
未找到文件。
telephony/telephonyjstest/netmanager_base/system_fetch/src/main/js/test/Http.fetch.test.js
浏览文件 @
9e765698
/**
/**
* Copyright (C) 2022-2023 Huawei Device Co., Ltd.
* Copyright (C) 2022-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")
...
@@ -15,7 +14,8 @@
...
@@ -15,7 +14,8 @@
*/
*/
import
fetch
from
'
@system.fetch
'
;
import
fetch
from
'
@system.fetch
'
;
import
{
describe
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
export
default
function
Telephony_NetStack_HttpFetchTest
()
{
export
default
function
Telephony_NetStack_HttpFetchTest
()
{
describe
(
"
Telephony_NetStack_HttpFetchTest
"
,
function
()
{
describe
(
"
Telephony_NetStack_HttpFetchTest
"
,
function
()
{
...
@@ -26,22 +26,31 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -26,22 +26,31 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchBasicGet_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchBasicGet_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/anything
"
,
url
:
"
https://httpbin.org/anything
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -50,25 +59,34 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -50,25 +59,34 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchUserAgent_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchUserAgent_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/user-agent
"
,
url
:
"
https://httpbin.org/user-agent
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack fetch complete
"
);
console
.
info
(
"
NetStack fetch complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -77,26 +95,35 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -77,26 +95,35 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchUserAgent_0200
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchUserAgent_0200
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/user-agent
"
,
url
:
"
https://httpbin.org/user-agent
"
,
responseType
:
"
json
"
,
responseType
:
"
json
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
data
.
data
[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
expect
(
data
.
data
[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack fetch complete
"
);
console
.
info
(
"
NetStack fetch complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -105,25 +132,34 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -105,25 +132,34 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchHeader_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchHeader_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/headers
"
,
url
:
"
https://httpbin.org/headers
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -132,26 +168,35 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -132,26 +168,35 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchHeader_0200
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchHeader_0200
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/headers
"
,
url
:
"
https://httpbin.org/headers
"
,
responseType
:
"
json
"
,
responseType
:
"
json
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
data
.
data
[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
();
expect
(
data
.
data
[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -160,27 +205,36 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -160,27 +205,36 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchPost_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchPost_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/post
"
,
url
:
"
https://httpbin.org/post
"
,
method
:
"
POST
"
,
method
:
"
POST
"
,
data
:
"
MineMine
"
,
data
:
"
MineMine
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
()
done
()
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -189,28 +243,37 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -189,28 +243,37 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchPost_0200
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchPost_0200
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/post
"
,
url
:
"
https://httpbin.org/post
"
,
method
:
"
POST
"
,
method
:
"
POST
"
,
data
:
"
MineMine
"
,
data
:
"
MineMine
"
,
responseType
:
"
json
"
,
responseType
:
"
json
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
data
.
data
[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
expect
(
data
.
data
[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -219,27 +282,36 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -219,27 +282,36 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchPut_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchPut_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/put
"
,
url
:
"
https://httpbin.org/put
"
,
method
:
"
PUT
"
,
method
:
"
PUT
"
,
data
:
"
MineMine
"
,
data
:
"
MineMine
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -248,28 +320,37 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -248,28 +320,37 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchPut_0200
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchPut_0200
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/put
"
,
url
:
"
https://httpbin.org/put
"
,
method
:
"
PUT
"
,
method
:
"
PUT
"
,
data
:
"
MineMine
"
,
data
:
"
MineMine
"
,
responseType
:
"
json
"
,
responseType
:
"
json
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
data
[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
expect
(
data
.
data
[
"
data
"
]
===
"
MineMine
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -278,14 +359,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -278,14 +359,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchUrlEncode_0100
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchUrlEncode_0100
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
url
:
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
data
:
{
data
:
{
"
name1
"
:
"
mine1
"
,
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
"
name2
"
:
"
mine2
"
,
},
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
key1
"
]
===
"
val1
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
key1
"
]
===
"
val1
"
).
assertTrue
();
...
@@ -293,17 +380,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -293,17 +380,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
name1
"
]
===
"
mine1
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
name1
"
]
===
"
mine1
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
name2
"
]
===
"
mine2
"
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
name2
"
]
===
"
mine2
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
/**
/**
...
@@ -312,15 +402,21 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -312,15 +402,21 @@ export default function Telephony_NetStack_HttpFetchTest() {
* @tc.desc function test
* @tc.desc function test
*/
*/
it
(
"
Telephony_NetStack_HttpTestFetchUrlEncode_0200
"
,
0
,
function
(
done
)
{
it
(
"
Telephony_NetStack_HttpTestFetchUrlEncode_0200
"
,
0
,
function
(
done
)
{
fetchTest
();
var
objectTimeOut
=
setTimeout
(
function
timeout
()
{
fetchTest
();
},
30000
);
function
fetchTest
()
{
fetch
.
fetch
({
fetch
.
fetch
({
url
:
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
url
:
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
data
:
{
data
:
{
"
name1
"
:
"
mine1
"
,
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
"
name2
"
:
"
mine2
"
,
},
},
responseType
:
"
json
"
,
responseType
:
"
json
"
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
expect
(
data
.
code
===
200
||
data
.
code
>
500
).
assertTrue
();
if
(
data
.
code
===
200
)
{
if
(
data
.
code
===
200
)
{
expect
(
data
.
data
[
"
key1
"
]
===
"
val1
"
).
assertTrue
();
expect
(
data
.
data
[
"
key1
"
]
===
"
val1
"
).
assertTrue
();
...
@@ -328,17 +424,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
...
@@ -328,17 +424,20 @@ export default function Telephony_NetStack_HttpFetchTest() {
expect
(
data
.
data
[
"
name1
"
]
===
"
mine1
"
).
assertTrue
();
expect
(
data
.
data
[
"
name1
"
]
===
"
mine1
"
).
assertTrue
();
expect
(
data
.
data
[
"
name2
"
]
===
"
mine2
"
).
assertTrue
();
expect
(
data
.
data
[
"
name2
"
]
===
"
mine2
"
).
assertTrue
();
}
}
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
fail
:
function
()
{
fail
:
function
()
{
console
.
info
(
"
NetStack Fetch Failed
"
);
console
.
info
(
"
NetStack Fetch Failed
"
);
expect
().
assertFail
();
expect
().
assertFail
();
clearTimeout
(
objectTimeOut
);
done
();
done
();
},
},
complete
:
function
()
{
complete
:
function
()
{
console
.
info
(
"
NetStack Fetch Complete
"
);
console
.
info
(
"
NetStack Fetch Complete
"
);
}
}
})
})
}
});
});
});
});
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录