From 67a290885a6930729b1873c4738f793cb0e97f8d Mon Sep 17 00:00:00 2001 From: VK <370725567@qq.com> Date: Wed, 11 Dec 2024 13:18:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85open-location.test.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/open-location/open-location.test.js | 60 +++++++++++++++++++ pages/API/open-location/open-location.uvue | 49 ++++++++++++--- 2 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 pages/API/open-location/open-location.test.js diff --git a/pages/API/open-location/open-location.test.js b/pages/API/open-location/open-location.test.js new file mode 100644 index 00000000..abb3e8cc --- /dev/null +++ b/pages/API/open-location/open-location.test.js @@ -0,0 +1,60 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') +const isIos = platformInfo.startsWith('ios') + +describe('dialog page', () => { + if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { + it('skip app-webview', () => { + expect(1).toBe(1) + }) + return + } + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + + let page; + let originLifeCycleNum; + beforeAll(async () => { + page = await program.reLaunch('/pages/API/open-location/open-location') + await page.waitFor('view'); + + originLifeCycleNum = await page.callMethod('getLifeCycleNum') + + await page.callMethod('openLocation') + await page.waitFor(1000) + }); + + it('dialogPage should empty', async () => { + const dialogPagesNum = await page.data('dialogPagesNum') + expect(dialogPagesNum).toBe(0) + }) + + it('should trigger parent hide', async () => { + const lifecycleNum = await page.callMethod('getLifeCycleNum') + expect(lifecycleNum).toBe(originLifeCycleNum - 1) + }) + if (isIos) { + // 15以下的模拟器所对应的xcode不能编译自定义插件,大于15是因为某台设备,会用xcode14.1跑15.5的设备 + let version = process.env.uniTestPlatformInfo + let split = version.split(" ") + version = parseInt(split[split.length - 1]) + if (version > 15) { + it('call openLocation in uts plugin', async () => { + page = await program.reLaunch('/pages/API/open-location/open-location') + await page.waitFor('view'); + await page.callMethod('openLocationByPlugin') + await page.waitFor(1000) + const lifecycleNum = await page.callMethod('getLifeCycleNum') + expect(lifecycleNum).toBe(originLifeCycleNum - 1) + }) + } + } + + afterAll(async () => { + await page.callMethod('setLifeCycleNum', originLifeCycleNum) + }); +}) diff --git a/pages/API/open-location/open-location.uvue b/pages/API/open-location/open-location.uvue index bd9d1dc7..17abe0df 100644 --- a/pages/API/open-location/open-location.uvue +++ b/pages/API/open-location/open-location.uvue @@ -47,7 +47,12 @@ - -- GitLab