From db9eea53f379b898a1a71352046f774da0127fab Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Thu, 21 Nov 2024 18:39:15 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A4=84=E7=90=86=E5=B0=8F?=
=?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/API/choose-location/choose-location.test.js | 6 +++---
pages/API/dialog-page/dialog-page.test.js | 9 ++++++++-
pages/API/get-app/get-app.test.js | 13 ++++++++-----
pages/API/get-app/get-app.uvue | 8 ++++++--
pages/API/get-current-pages/get-current-pages.uvue | 4 ++--
5 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/pages/API/choose-location/choose-location.test.js b/pages/API/choose-location/choose-location.test.js
index 0c5d08ce..0dc82f5a 100644
--- a/pages/API/choose-location/choose-location.test.js
+++ b/pages/API/choose-location/choose-location.test.js
@@ -1,5 +1,5 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
-isWeixin = platformInfo == 'mp-weixin'
+const isMP = platformInfo.startsWith('mp')
describe('dialog page', () => {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
@@ -8,8 +8,8 @@ describe('dialog page', () => {
})
return
}
- if (isWeixin) {
- it('skip app-webview', () => {
+ if (isMP) {
+ it('skip mp', () => {
expect(1).toBe(1)
})
return
diff --git a/pages/API/dialog-page/dialog-page.test.js b/pages/API/dialog-page/dialog-page.test.js
index e978d639..ccdb05a1 100644
--- a/pages/API/dialog-page/dialog-page.test.js
+++ b/pages/API/dialog-page/dialog-page.test.js
@@ -3,6 +3,7 @@ jest.setTimeout(20000)
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
const isAndroid = platformInfo.startsWith('android')
+const isMP = platformInfo.startsWith('mp')
const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
@@ -13,6 +14,12 @@ describe('dialog page', () => {
})
return
}
+ if (isMP) {
+ it('skip mp', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
let page;
let initLifeCycleNum;
@@ -51,7 +58,7 @@ describe('dialog page', () => {
it('check dialogPage methods', async () => {
expect(await page.callMethod('dialogPageCheckGetDialogPages')).toBe(true)
let dialogPageStyle = await page.callMethod('dialogPageGetPageStyle')
- expect(dialogPageStyle.backgroundColorContent).not.toBe('red')
+ expect(dialogPageStyle.backgroundColorContent).not.toBe('red')
await page.callMethod('dialogPageSetPageStyle')
dialogPageStyle = await page.callMethod('dialogPageGetPageStyle')
expect(dialogPageStyle.backgroundColorContent).toBe('red')
diff --git a/pages/API/get-app/get-app.test.js b/pages/API/get-app/get-app.test.js
index c8306e52..a0a5014f 100644
--- a/pages/API/get-app/get-app.test.js
+++ b/pages/API/get-app/get-app.test.js
@@ -1,6 +1,7 @@
const PAGE_PATH = '/pages/API/get-app/get-app'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
-const isAndroid = platformInfo.startsWith('android')
+const isAndroid = platformInfo.startsWith('android')
+const isMP = platformInfo.startsWith('mp')
describe('getApp', () => {
let page = null
@@ -49,8 +50,10 @@ describe('getApp', () => {
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
})
- it('getAndroidApplication', async () => {
- const res = await page.callMethod('getAndroidApplication')
- expect(res).toBe(isAndroid)
- })
+ if (!isMP) {
+ it('getAndroidApplication', async () => {
+ const res = await page.callMethod('getAndroidApplication')
+ expect(res).toBe(isAndroid)
+ })
+ }
})
diff --git a/pages/API/get-app/get-app.uvue b/pages/API/get-app/get-app.uvue
index f1c2b08a..64a2ef8b 100644
--- a/pages/API/get-app/get-app.uvue
+++ b/pages/API/get-app/get-app.uvue
@@ -38,11 +38,13 @@
- lifeCycleNum: {{ lifeCycleNum }}
+ lifeCycleNum: {{ lifeCycleNum }}
+
androidApplication is null: {{ androidApplication == null }}
+
@@ -172,12 +174,14 @@
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
- },
+ },
+ // #ifndef MP
getAndroidApplication() : boolean {
const app = getApp()
this.androidApplication = app.getAndroidApplication()
return this.androidApplication !== null
}
+ // #endif
},
}
diff --git a/pages/API/get-current-pages/get-current-pages.uvue b/pages/API/get-current-pages/get-current-pages.uvue
index 62a3b3ee..bcc791c1 100644
--- a/pages/API/get-current-pages/get-current-pages.uvue
+++ b/pages/API/get-current-pages/get-current-pages.uvue
@@ -93,12 +93,12 @@
}
},
onLoad(options : OnLoadOptions) {
- // #ifndef APP-ANDROID
+ // #ifdef APP-IOS || WEB
if (options instanceof UTSJSONObject) {
this.checked = true
}
// #endif
- // #ifdef APP-ANDROID
+ // #ifndef APP-IOS || WEB
this.checked = true
// #endif
this.getPageStyle();
--
GitLab