From a43c96992a29afc14278e95a87e56b771ae3379e Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sat, 16 Nov 2024 17:35:02 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=20chooseLocation=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choose-location/choose-location.test.js | 21 +++++++++++++++++++ .../API/choose-location/choose-location.uvue | 9 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 pages/API/choose-location/choose-location.test.js diff --git a/pages/API/choose-location/choose-location.test.js b/pages/API/choose-location/choose-location.test.js new file mode 100644 index 00000000..7f64fbe8 --- /dev/null +++ b/pages/API/choose-location/choose-location.test.js @@ -0,0 +1,21 @@ +describe('dialog page', () => { + if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { + it('skip app-webview', () => { + expect(1).toBe(1) + }) + return + } + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/API/choose-location/choose-location') + await page.waitFor('view'); + }); + + it('dialogPage should empty', async () => { + await page.callMethod('chooseLocation') + await page.waitFor(1000) + const dialogPagesNum = await page.data('dialogPagesNum') + expect(dialogPagesNum).toBe(0) + }) +}) diff --git a/pages/API/choose-location/choose-location.uvue b/pages/API/choose-location/choose-location.uvue index 6d8e3020..2a4e22f5 100644 --- a/pages/API/choose-location/choose-location.uvue +++ b/pages/API/choose-location/choose-location.uvue @@ -39,7 +39,8 @@ latitude: [], longitude: [] } as Location, - locationAddress: '' + locationAddress: '', + dialogPagesNum: -1 } }, methods: { @@ -52,6 +53,12 @@ this.locationAddress = res.address } }) + setTimeout(() => { + const pages = getCurrentPages() + const page = pages[pages.length - 1] + const dialogPages = page.getDialogPages() + this.dialogPagesNum = dialogPages.length + }, 500) }, formatLocation: function(longitude:number, latitude:number):Location { const longitudeArr = longitude.toString().split('.') -- GitLab