Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
187c1143
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6412
Star
112
Fork
189
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
25
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
25
Issue
25
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
187c1143
编写于
5月 17, 2024
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 网络相关api增加插件中调用的测试
上级
4eb715b1
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
316 addition
and
5 deletion
+316
-5
pages/API/download-file/download-file.test.js
pages/API/download-file/download-file.test.js
+8
-1
pages/API/download-file/download-file.uvue
pages/API/download-file/download-file.uvue
+18
-1
pages/API/request/request.test.js
pages/API/request/request.test.js
+6
-0
pages/API/request/request.uvue
pages/API/request/request.uvue
+19
-1
pages/API/upload-file/upload-file.test.js
pages/API/upload-file/upload-file.test.js
+8
-1
pages/API/upload-file/upload-file.uvue
pages/API/upload-file/upload-file.uvue
+18
-1
uni_modules/test-invoke-network-api/changelog.md
uni_modules/test-invoke-network-api/changelog.md
+0
-0
uni_modules/test-invoke-network-api/package.json
uni_modules/test-invoke-network-api/package.json
+82
-0
uni_modules/test-invoke-network-api/readme.md
uni_modules/test-invoke-network-api/readme.md
+6
-0
uni_modules/test-invoke-network-api/utssdk/app-android/config.json
...es/test-invoke-network-api/utssdk/app-android/config.json
+3
-0
uni_modules/test-invoke-network-api/utssdk/app-android/index.uts
...ules/test-invoke-network-api/utssdk/app-android/index.uts
+64
-0
uni_modules/test-invoke-network-api/utssdk/app-ios/config.json
...odules/test-invoke-network-api/utssdk/app-ios/config.json
+3
-0
uni_modules/test-invoke-network-api/utssdk/app-ios/index.uts
uni_modules/test-invoke-network-api/utssdk/app-ios/index.uts
+64
-0
uni_modules/test-invoke-network-api/utssdk/interface.uts
uni_modules/test-invoke-network-api/utssdk/interface.uts
+17
-0
uni_modules/test-invoke-network-api/utssdk/unierror.uts
uni_modules/test-invoke-network-api/utssdk/unierror.uts
+0
-0
未找到文件。
pages/API/download-file/download-file.test.js
浏览文件 @
187c1143
...
...
@@ -29,7 +29,14 @@ describe('ExtApi-DownloadFile', () => {
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
);
});
});
it
(
'
Check Download File In UTS Module
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_uts_module_invoked
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
}
...
...
pages/API/download-file/download-file.uvue
浏览文件 @
187c1143
...
...
@@ -18,7 +18,12 @@
</scroll-view>
<!-- #endif -->
</template>
<script>
<script>
import {
testInovkeDownloadFile,
CommonOptions
} from '@/uni_modules/test-invoke-network-api'
export default {
data() {
return {
...
...
@@ -127,6 +132,18 @@
this.jest_result = needCookie ? false : true;
}
});
},
jest_uts_module_invoked(){
testInovkeDownloadFile({
success:(res: any)=>{
console.log("success :", res);
this.jest_result = true
},
fail:(err: any)=>{
console.log("fail :", err);
this.jest_result = false
}
} as CommonOptions)
}
}
}
...
...
pages/API/request/request.test.js
浏览文件 @
187c1143
...
...
@@ -129,5 +129,11 @@ describe('ExtApi-Request', () => {
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
it
(
'
Check Post In UTS Module
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_uts_module_invoked
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
});
pages/API/request/request.uvue
浏览文件 @
187c1143
...
...
@@ -69,6 +69,12 @@
</view>
</template>
<script>
import {
testInovkeRequest,
CommonOptions
} from '@/uni_modules/test-invoke-network-api'
class GETDataType {
data: UTSJSONObject | null = null
}
...
...
@@ -275,7 +281,7 @@
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res) => {
success: (res) => {
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
console.log("requestCookie ", requestCookie);
if (requestCookie instanceof Array) {
...
...
@@ -357,6 +363,18 @@
this.jest_result = false
}
});
},
jest_uts_module_invoked(){
testInovkeRequest({
success:(res: any)=>{
console.log("success :", res);
this.jest_result = true
},
fail:(err: any)=>{
console.log("fail :", err);
this.jest_result = false
}
} as CommonOptions)
}
}
}
...
...
pages/API/upload-file/upload-file.test.js
浏览文件 @
187c1143
...
...
@@ -34,7 +34,14 @@ describe('ExtApi-UploadFile', () => {
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
});
it
(
'
Check Upload File In UTS Module
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_uts_module_invoked
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
})
let
shouldTestCookie
=
false
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
...
...
pages/API/upload-file/upload-file.uvue
浏览文件 @
187c1143
...
...
@@ -15,7 +15,12 @@
</scroll-view>
<!-- #endif -->
</template>
<script>
<script>
import {
testInovkeUploadFile,
CommonOptions
} from '@/uni_modules/test-invoke-network-api'
export default {
data() {
return {
...
...
@@ -171,6 +176,18 @@
this.jest_result = false;
},
})
},
jest_uts_module_invoked(){
testInovkeUploadFile({
success:(res: any)=>{
console.log("success :", res);
this.jest_result = true
},
fail:(err: any)=>{
console.log("fail :", err);
this.jest_result = false
}
} as CommonOptions)
}
}
}
...
...
uni_modules/test-invoke-network-api/changelog.md
0 → 100644
浏览文件 @
187c1143
uni_modules/test-invoke-network-api/package.json
0 → 100644
浏览文件 @
187c1143
{
"id"
:
"test-invoke-network-api"
,
"displayName"
:
"test-invoke-network-api"
,
"version"
:
"1.0.0"
,
"description"
:
"测试UTS插件中访问网络相关接口"
,
"keywords"
:
[
"test-invoke-network-api"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.8"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
,
"alipay"
:
"u"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"u"
,
"vue3"
:
"u"
},
"App"
:
{
"app-android"
:
"u"
,
"app-ios"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"u"
,
"Android Browser"
:
"u"
,
"微信浏览器(Android)"
:
"u"
,
"QQ浏览器(Android)"
:
"u"
},
"H5-pc"
:
{
"Chrome"
:
"u"
,
"IE"
:
"u"
,
"Edge"
:
"u"
,
"Firefox"
:
"u"
,
"Safari"
:
"u"
},
"小程序"
:
{
"微信"
:
"u"
,
"阿里"
:
"u"
,
"百度"
:
"u"
,
"字节跳动"
:
"u"
,
"QQ"
:
"u"
,
"钉钉"
:
"u"
,
"快手"
:
"u"
,
"飞书"
:
"u"
,
"京东"
:
"u"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
uni_modules/test-invoke-network-api/readme.md
0 → 100644
浏览文件 @
187c1143
# test-invoke-network-api
### 开发文档
[
UTS 语法
](
https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html
)
[
UTS API插件
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
)
[
UTS 组件插件
](
https://uniapp.dcloud.net.cn/plugin/uts-component.html
)
[
Hello UTS
](
https://gitcode.net/dcloud/hello-uts
)
\ No newline at end of file
uni_modules/test-invoke-network-api/utssdk/app-android/config.json
0 → 100644
浏览文件 @
187c1143
{
"minSdkVersion"
:
"21"
}
\ No newline at end of file
uni_modules/test-invoke-network-api/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
187c1143
import { CommonOptions } from '../interface.uts'
export function testInovkeRequest(options : CommonOptions) : void {
uni.request<any>({
url: "https://request.dcloud.net.cn/api/http/method/post",
method: "POST",
header: {
"Cookie": "token11222"
} as UTSJSONObject,
timeout: 6000,
sslVerify: false,
withCredentials: false,
data: {
"platform": {
"abc": "xyq"
},
},
firstIpv4: false,
success: (res : RequestSuccess<any>) => {
options.success?.(res)
},
fail(e : RequestFail) {
options.fail?.(e)
},
} as RequestOptions<any>)
}
export function testInovkeUploadFile(options : CommonOptions) : void {
const imageSrc = "/static/uni.png";
uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload',
files: [
{
name: "file1",
uri: imageSrc
} as UploadFileOptionFiles,
{
name: "file2",
uri: imageSrc
} as UploadFileOptionFiles
],
success: (res : UploadFileSuccess) => {
options.success?.(res)
},
fail: (err : UploadFileFail) => {
options.fail?.(err)
},
} as UploadFileOptions)
}
export function testInovkeDownloadFile(options : CommonOptions) : void {
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: `${uni.env.CACHE_PATH}/halo/world/`,
success(res : DownloadFileSuccess) {
options.success?.(res)
},
fail(e : DownloadFileFail) {
options.fail?.(e)
}
} as DownloadFileOptions);
}
uni_modules/test-invoke-network-api/utssdk/app-ios/config.json
0 → 100644
浏览文件 @
187c1143
{
"deploymentTarget"
:
"9"
}
\ No newline at end of file
uni_modules/test-invoke-network-api/utssdk/app-ios/index.uts
0 → 100644
浏览文件 @
187c1143
import { CommonOptions } from '../interface.uts'
export function testInovkeRequest(options : CommonOptions) : void {
uni.request<any>({
url: "https://request.dcloud.net.cn/api/http/method/post",
method: "POST",
header: {
"Cookie": "token11222"
} as UTSJSONObject,
timeout: 6000,
sslVerify: false,
withCredentials: false,
data: {
"platform": {
"abc": "xyq"
},
},
firstIpv4: false,
success: (res : RequestSuccess<any>) => {
options.success?.(res)
},
fail(e : RequestFail) {
options.fail?.(e)
},
} as RequestOptions<any>)
}
export function testInovkeUploadFile(options : CommonOptions) : void {
const imageSrc = "/static/uni.png";
uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload',
files: [
{
name: "file1",
uri: imageSrc
} as UploadFileOptionFiles,
{
name: "file2",
uri: imageSrc
} as UploadFileOptionFiles
],
success: (res : UploadFileSuccess) => {
options.success?.(res)
},
fail: (err : UploadFileFail) => {
options.fail?.(err)
},
} as UploadFileOptions)
}
export function testInovkeDownloadFile(options : CommonOptions) : void {
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: `${uni.env.CACHE_PATH}/halo/world/`,
success(res : DownloadFileSuccess) {
options.success?.(res)
},
fail(e : DownloadFileFail) {
options.fail?.(e)
}
} as DownloadFileOptions);
}
uni_modules/test-invoke-network-api/utssdk/interface.uts
0 → 100644
浏览文件 @
187c1143
export type CommonOptions = {
success ?: (res: any) => void
fail ?: (res : any) => void
}
export type testInovkeRequest = (options : CommonOptions) => void
export type testInovkeUploadFile = (options : CommonOptions) => void
export type testInovkeDownloadFile = (options : CommonOptions) => void
uni_modules/test-invoke-network-api/utssdk/unierror.uts
0 → 100644
浏览文件 @
187c1143
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录