diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..9b41ee42097f2cf6240fd095bc47f1dafe551f33
--- /dev/null
+++ b/pages/API/download-file/download-file.test.js
@@ -0,0 +1,18 @@
+const PAGE_PATH = '/pages/API/download-file/download-file'
+
+describe('ExtApi-DownloadFile', () => {
+
+ let page;
+ let res;
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ await page.callMethod('jest_downloadFile');
+ await page.waitFor(500);
+ res = await page.data('jest_result');
+ });
+
+ it('Check ', async () => {
+ expect(res).toBe(true);
+ });
+});
diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue
index db8119358f7ac195b809f659a607603d6c87706e..0b00386498952ed858f520c7b577357a0293853e 100644
--- a/pages/API/download-file/download-file.uvue
+++ b/pages/API/download-file/download-file.uvue
@@ -27,7 +27,9 @@ export default {
title: 'downloadFile',
imageSrc: '',
task: null as DownloadTask | null,
- pageVisible: false
+ pageVisible: false,
+ //自动化测试例专用
+ jest_result: false
}
},
onLoad() {
@@ -66,7 +68,19 @@ export default {
console.log("progress : ", update.progress);
}
})
- }
+ },
+ //自动化测试例专用
+ jest_downloadFile(){
+ uni.downloadFile({
+ url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
+ success() {
+ this.jest_result = true
+ },
+ fail: () => {
+ this.jest_result = false
+ }
+ });
+ }
}
}
diff --git a/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js b/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f182c9431135bc9321d0c6fbb2e1fae50245ead6
--- /dev/null
+++ b/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js
@@ -0,0 +1,34 @@
+const PAGE_PATH = '/pages/API/get-app-authorize-setting/get-app-authorize-setting'
+
+describe('ExtApi-GetAppAuthorizeSetting', () => {
+
+ let page;
+ let res;
+ let commonSupportList = [
+ 'authorized', 'denied', 'not determined', 'config error'
+ ]
+ let locationAccuracySupportList = [
+ 'reduced', 'full', 'unsupported'
+ ]
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await uni.getAppAuthorizeSetting();
+ });
+ it('Check cameraAuthorized', async () => {
+ expect(commonSupportList).toContain(res.cameraAuthorized)
+ });
+
+ it('Check locationAuthorized', async () => {
+ expect(commonSupportList).toContain(res.locationAuthorized)
+ });
+ it('Check locationAccuracy', async () => {
+ expect(locationAccuracySupportList).toContain(res.locationAccuracy)
+ });
+ it('Check microphoneAuthorized', async () => {
+ expect(commonSupportList).toContain(res.microphoneAuthorized)
+ });
+ it('Check notificationAuthorized', async () => {
+ expect(commonSupportList).toContain(res.notificationAuthorized)
+ });
+});
diff --git a/pages/API/get-app-base-info/get-app-base-info.test.js b/pages/API/get-app-base-info/get-app-base-info.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..b0a255f3b0c91048514b32b15b316c1e41a34e59
--- /dev/null
+++ b/pages/API/get-app-base-info/get-app-base-info.test.js
@@ -0,0 +1,31 @@
+const PAGE_PATH = '/pages/API/get-app-base-info/get-app-base-info'
+
+describe('ExtApi-GetAppBaseInfo', () => {
+
+ let page;
+ let res;
+ const stringProperties = [
+ 'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage',
+ 'language', 'version', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion',
+ ]
+ const numberProperties = [
+ 'uniCompileVersionCode', 'uniRuntimeVersionCode'
+ ]
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await uni.getAppBaseInfo();
+ });
+ it('Check properties', async () => {
+ for (const key in res) {
+ const value = res[key];
+ expect(value).not.toBeNull();
+ if (stringProperties.indexOf(key) != -1) {
+ expect(value).not.toBe("");
+ }
+ if (numberProperties.indexOf(key) != -1) {
+ expect(value).toBeGreaterThanOrEqual(3.90);
+ }
+ }
+ });
+});
diff --git a/pages/API/get-device-info/get-device-info.test.js b/pages/API/get-device-info/get-device-info.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..6776ab30a61e09848c15acda57eb563dabbcddc9
--- /dev/null
+++ b/pages/API/get-device-info/get-device-info.test.js
@@ -0,0 +1,28 @@
+const PAGE_PATH = '/pages/API/get-device-info/get-device-info'
+
+describe('ExtApi-GetDeviceInfo', () => {
+
+ let page;
+ let res;
+ const stringProperties = [
+ 'brand', 'deviceBrand', 'deviceId', 'model', 'deviceModel',
+ 'deviceType', 'devicePixelRatio', 'system', 'platform', 'uniRuntimeVersion',
+ ]
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await uni.getDeviceInfo();
+ });
+ it('Check properties', async () => {
+ for (const key in res) {
+ const value = res[key];
+ expect(value).not.toBeNull();
+ if (stringProperties.indexOf(key) != -1) {
+ expect(value).not.toBe("");
+ }
+ if (key == 'deviceOrientation') {
+ expect(['portrait', 'landscape']).toContain(value);
+ }
+ }
+ });
+});
diff --git a/pages/API/get-network-type/get-network-type.test.js b/pages/API/get-network-type/get-network-type.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e7cb59470a75f9b5ff31a7ab1c5da811b920f6c
--- /dev/null
+++ b/pages/API/get-network-type/get-network-type.test.js
@@ -0,0 +1,18 @@
+const PAGE_PATH = '/pages/API/get-network-type/get-network-type'
+
+describe('ExtApi-GetNetworkType', () => {
+
+ let page;
+ let res;
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ await page.callMethod('jest_getNetworkType');
+ await page.waitFor(200);
+ res = await page.data('jest_result');
+ });
+
+ it('Check ', async () => {
+ expect(res).toBe(true);
+ });
+});
diff --git a/pages/API/get-network-type/get-network-type.uvue b/pages/API/get-network-type/get-network-type.uvue
index 401bc502ab0f0a7136412b4b5bb042e88dbacbcb..dcae67e586dbe9c737135e900e9e30e4c13e33b7 100644
--- a/pages/API/get-network-type/get-network-type.uvue
+++ b/pages/API/get-network-type/get-network-type.uvue
@@ -27,7 +27,9 @@
hasNetworkType: false,
networkType: '',
connectedWifi: '',
- pageVisible: false
+ pageVisible: false,
+ //自动化测试例专用
+ jest_result:false,
}
},
onLoad() {
@@ -60,7 +62,18 @@
this.hasNetworkType = false;
this.networkType = '';
this.connectedWifi = '';
- },
+ },
+ //自动化测试例专用
+ jest_getNetworkType(){
+ uni.getNetworkType({
+ success: () => {
+ this.jest_result = true;
+ },
+ fail: () => {
+ this.jest_result = false;
+ }
+ })
+ }
}
}
diff --git a/pages/API/get-system-info/get-system-info.test.js b/pages/API/get-system-info/get-system-info.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7e9685bfb238f7b9c363ae12a03a1f5f7131634f
--- /dev/null
+++ b/pages/API/get-system-info/get-system-info.test.js
@@ -0,0 +1,40 @@
+const PAGE_PATH = '/pages/API/get-system-info/get-system-info'
+
+describe('ExtApi-GetSystemInfo', () => {
+
+ let page;
+ let res;
+ const stringProperties = [
+ 'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode',
+ 'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language',
+ 'model', 'version', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion',
+ 'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion',
+ ]
+ const numberProperties = [
+ 'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
+ 'windowWidth',
+ 'windowHeight', 'windowTop', 'windowBottom', 'screenTop',
+ 'uniCompileVersionCode', 'uniRuntimeVersionCode'
+ ]
+
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await page.callMethod('jest_getSystemInfo')
+ });
+ it('Check GetSystemInfoSync', async () => {
+ for (const key in res) {
+ const value = res[key];
+ expect(value).not.toBeNull();
+ if (stringProperties.indexOf(key) != -1) {
+ expect(value).not.toBe("");
+ }
+ if (numberProperties.indexOf(key) != -1) {
+ expect(value).toBeGreaterThanOrEqual(0);
+ }
+ if (key == 'deviceOrientation') {
+ expect(['portrait', 'landscape']).toContain(value);
+ }
+ }
+ });
+});
\ No newline at end of file
diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue
index f766b13292355c0b50755b5e2b2c7e537c6241f5..5606658305f88b690cc2a3ccd59c8419563392c9 100644
--- a/pages/API/get-system-info/get-system-info.uvue
+++ b/pages/API/get-system-info/get-system-info.uvue
@@ -69,7 +69,11 @@ export default {
}
},
})
- }
+ },
+ //自动化测试例专用
+ jest_getSystemInfo():GetSystemInfoResult{
+ return uni.getSystemInfoSync();
+ },
}
}
diff --git a/pages/API/get-system-setting/get-system-setting.test.js b/pages/API/get-system-setting/get-system-setting.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..851dd0764f3c772cee6bdc2af1e44a4469b82f84
--- /dev/null
+++ b/pages/API/get-system-setting/get-system-setting.test.js
@@ -0,0 +1,32 @@
+const PAGE_PATH = '/pages/API/get-system-setting/get-system-setting'
+
+describe('ExtApi-GetSystemSetting', () => {
+
+ let page;
+ let res;
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await uni.getSystemSetting()
+ });
+ it('Check GetSystemSetting', async () => {
+ for (const key in res) {
+ const value = res[key];
+ if (res['bluetoothEnabled'] == undefined) {
+ expect(res['bluetoothError']).not.toBe("")
+ } else {
+ expect(res['bluetoothError'] == undefined).toBe(true)
+ }
+
+ if (res['wifiEnabled'] == undefined) {
+ expect(res['wifiError']).not.toBe("")
+ } else {
+ expect(res['wifiError'] == undefined).toBe(true)
+ }
+
+ if (key == 'deviceOrientation') {
+ expect(['portrait', 'landscape']).toContain(value);
+ }
+ }
+ });
+});
diff --git a/pages/API/get-window-info/get-window-info.test.js b/pages/API/get-window-info/get-window-info.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a6a636178c22548973017942059bbf4a719584df
--- /dev/null
+++ b/pages/API/get-window-info/get-window-info.test.js
@@ -0,0 +1,28 @@
+const PAGE_PATH = '/pages/API/get-window-info/get-window-info'
+
+describe('ExtApi-GetWindowInfo', () => {
+
+ let page;
+ let res;
+ const numberProperties = [
+ 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
+ 'windowWidth',
+ 'windowHeight', 'windowTop', 'windowBottom', 'screenTop'
+ ]
+
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ res = await page.callMethod('jest_getWindowInfo')
+ });
+
+ it('Check GetWindowInfo', async () => {
+ for (const key in res) {
+ const value = res[key];
+ expect(value).not.toBeNull();
+ if (numberProperties.indexOf(key) != -1) {
+ expect(value).toBeGreaterThanOrEqual(0);
+ }
+ }
+ });
+});
diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue
index 6e46c572839befe36e6da9f8c26608346370b8af..54cc9b23ce4ff9ef82a2c0698039be8fabb3d7e7 100644
--- a/pages/API/get-window-info/get-window-info.uvue
+++ b/pages/API/get-window-info/get-window-info.uvue
@@ -47,7 +47,11 @@
this.items.push(item);
}
}
- }
+ },
+ //自动化测试例专用
+ jest_getWindowInfo():GetWindowInfoResult{
+ return uni.getWindowInfo();
+ },
}
}
diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..58555dcb047e4b3aa77e7aec666793b2cf3dc543
--- /dev/null
+++ b/pages/API/request/request.test.js
@@ -0,0 +1,79 @@
+const PAGE_PATH = '/pages/API/request/request'
+
+
+const methodMap = {
+ "GET": "/api/http/method/get",
+ "POST": "/api/http/method/post",
+ "PUT": "/api/http/method/put",
+ "DELETE": "/api/http/method/delete",
+ "PATCH": "/api/http/method/patch",
+ "OPTIONS": "/api/http/method/options",
+ "HEAD": "/api/http/method/head"
+}
+
+async function request(page, method, header, data, url) {
+ if (url == null) {
+ url = methodMap[method]
+ }
+ await page.setData({
+ url: url,
+ method: method,
+ data: data,
+ header: header
+ })
+ res = await page.callMethod('jest_request')
+ await page.waitFor(200);
+ res = await page.data('jest_result');
+ expect(res).toBe(true)
+}
+
+describe('ExtApi-Request', () => {
+ let page;
+ let res;
+
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ });
+
+
+ beforeEach(async () => {
+ await page.setData({
+ jest_result: false,
+ data: null,
+ header: null
+ })
+ });
+
+
+ it('Check GET', async () => {
+ await request(page, 'GET');
+ });
+ it('Check POST ContentType Json', async () => {
+ await request(page, 'POST', {
+ "Content-Type": "application/json"
+ }, {
+ "hello": "world"
+ }, "/api/http/contentType/json");
+ });
+ it('Check POST ContentType Form', async () => {
+ await request(page, 'POST', {
+ "Content-Type": "application/x-www-form-urlencoded"
+ }, "hello=world", "/api/http/contentType/xWwwFormUrlencoded");
+ });
+ it('Check PUT', async () => {
+ await request(page, 'PUT');
+ });
+ it('Check DELETE', async () => {
+ await request(page, 'DELETE');
+ });
+ it('Check PATCH', async () => {
+ await request(page, 'PATCH');
+ });
+ it('Check OPTIONS', async () => {
+ await request(page, 'OPTIONS');
+ });
+ it('Check HEAD', async () => {
+ await request(page, 'HEAD');
+ });
+});
diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue
index 944fde30f43f5a801a7724e4b6558bfb71b87603..fbe4f7d2d08537a85ae45e926ba56657178fffb2 100644
--- a/pages/API/request/request.uvue
+++ b/pages/API/request/request.uvue
@@ -1,220 +1,242 @@
-
-
-
-
-
-
- 地址 : {{ host + url}}
- 请求方式 : {{method}}
-
-
-
-
-
-
-
- 设置请求方式
-
-
-
-
-
-
-
-
-
-
-
-
- 请求返回错误码的接口(默认为GET)
-
-
-
-
-
-
- 请求不同header的接口(默认为GET)
-
-
-
-
-
-
- 请求不同content-type的接口(默认为GET)
-
-
-
-
-
+
+
+
+
+
+
+ 地址 : {{ host + url}}
+ 请求方式 : {{method}}
+
+
+
+
+
+
+
+ 设置请求方式
+
+
+
+
+
+
+
+
+
+
+
+
+ 请求返回错误码的接口(默认为GET)
+
+
+
+
+
+
+ 请求不同header的接口(默认为GET)
+
+
+
+
+
+
+ 请求不同content-type的接口(默认为GET)
+
+
+
+
+
-
- POST请求(有body)
-
-
-
-
-
-
-
+
+ POST请求(有body)
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/API/upload-file/upload-file.test.js b/pages/API/upload-file/upload-file.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..b02e2bc12f1307e983d2717960a0a4354dcdc043
--- /dev/null
+++ b/pages/API/upload-file/upload-file.test.js
@@ -0,0 +1,18 @@
+const PAGE_PATH = '/pages/API/upload-file/upload-file'
+
+describe('ExtApi-UploadFile', () => {
+
+ let page;
+ let res;
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ await page.callMethod('jest_uploadFile');
+ await page.waitFor(500);
+ res = await page.data('jest_result');
+ });
+
+ it('Check ', async () => {
+ expect(res).toBe(true);
+ });
+});
diff --git a/pages/API/upload-file/upload-file.uvue b/pages/API/upload-file/upload-file.uvue
index fb36444cf1ba64997721e17c733c92f7f69cd518..d239c13886d2b5f8e7048bc7336d3adaef99db76 100644
--- a/pages/API/upload-file/upload-file.uvue
+++ b/pages/API/upload-file/upload-file.uvue
@@ -29,7 +29,9 @@ export default {
title: 'uploadFile',
imageSrc: '',
task: null as UploadTask | null,
- pageVisible: false
+ pageVisible: false,
+ //自动化测试例专用
+ jest_result:false,
}
},
onLoad() {
@@ -52,7 +54,7 @@ export default {
var imageSrc = res.tempFilePaths[0]
uni.showLoading({
title: '上传中'
- })
+ })
this.task = uni.uploadFile({
url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址
filePath: imageSrc,
@@ -88,7 +90,25 @@ export default {
console.log('chooseImage fail', err)
}
})
- }
+ },
+ //自动化测试例专用
+ jest_uploadFile(){
+ const imageSrc = "/static/uni.png";
+ this.task = uni.uploadFile({
+ url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址
+ filePath: imageSrc,
+ name: 'file',
+ formData: {
+ 'user': 'test'
+ },
+ success: () => {
+ this.jest_result = true;
+ },
+ fail: () => {
+ this.jest_result = false;
+ },
+ })
+ }
}
}
diff --git a/pages/API/websocket-socketTask/websocket-socketTask.test.js b/pages/API/websocket-socketTask/websocket-socketTask.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..6a3bc3d3b279d2f7a94022abb395813b5255b207
--- /dev/null
+++ b/pages/API/websocket-socketTask/websocket-socketTask.test.js
@@ -0,0 +1,18 @@
+const PAGE_PATH = '/pages/API/websocket-socketTask/websocket-socketTask'
+
+describe('ExtApi-WebSocket', () => {
+
+ let page;
+ let res;
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ await page.callMethod('jest_connectSocket');
+ await page.waitFor(500);
+ res = await page.data('jest_result');
+ });
+
+ it('Check ', async () => {
+ expect(res).toBe(2);
+ });
+});
diff --git a/pages/API/websocket-socketTask/websocket-socketTask.uvue b/pages/API/websocket-socketTask/websocket-socketTask.uvue
index 4cc2369a56cd5818a516f112536004f738a35408..8285294b15fd30778b811079ee00caf181d52ee5 100644
--- a/pages/API/websocket-socketTask/websocket-socketTask.uvue
+++ b/pages/API/websocket-socketTask/websocket-socketTask.uvue
@@ -35,7 +35,9 @@ export default {
socketTask: null as SocketTask | null,
msg: '',
platform: '',
- pageVisible: false,
+ pageVisible: false,
+ //自动化测试例专用
+ jest_result: 0,
}
},
computed: {
@@ -144,7 +146,7 @@ export default {
this.socketTask?.send({
data,
success(res: any) {
- console.log(res)
+ console.log(res)
},
fail(err: any) {
console.log(err)
@@ -162,7 +164,38 @@ export default {
console.log('uni.closeSocket fail', err)
},
} as CloseSocketOptions)
- },
+ },
+ //自动化测试例专用
+ jest_connectSocket(){
+ this.socketTask = uni.connectSocket({
+ url: 'ws://websocket.dcloud.net.cn',
+ success:(_) => {
+ this.jest_result++
+ },
+ fail:(_) => {
+ this.jest_result = 0
+ },
+ })
+ this.socketTask?.onOpen((_) => {
+ const data =
+ 'from ' +
+ this.platform +
+ ' : ' +
+ parseInt(Math.random() * 10000 + '').toString()
+ this.socketTask?.send({
+ data,
+ success(_) {
+ this.jest_result++
+ },
+ fail(_) {
+ this.jest_result = 0
+ },
+ } as SendSocketMessageOptions)
+ })
+ this.socketTask?.onError((_) => {
+ this.jest_result = 0;
+ })
+ }
},
}