From 14cffd7449c976f9b62fcad870f61987dbe13fdd Mon Sep 17 00:00:00 2001 From: jixinbao Date: Mon, 6 May 2024 11:43:40 +0800 Subject: [PATCH] =?UTF-8?q?test(api/interceptor):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=99=A8=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/interceptor/interceptor.test.js | 28 +++++++++++++++++++++-- pages/API/interceptor/interceptor.uvue | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pages/API/interceptor/interceptor.test.js b/pages/API/interceptor/interceptor.test.js index 5006a8a6..1c475186 100644 --- a/pages/API/interceptor/interceptor.test.js +++ b/pages/API/interceptor/interceptor.test.js @@ -12,7 +12,15 @@ describe('interceptor', () => { await newPage.waitFor('text') const num = (await newPage.data()).page await program.navigateBack() - expect(num).toBe(1) + expect(num).toBe(1) + // 新增 navigator 元素 + const elementNavigatorButton = await page.$('.navigatorButton') + await elementNavigatorButton.tap() + await page.waitFor(300) + + const currentPage = await program.currentPage() + expect(currentPage.path).toBe('pages/API/interceptor/page1') + await program.navigateBack() }) it('addInterceptor', async () => { @@ -22,6 +30,14 @@ describe('interceptor', () => { const num = (await newPage.data()).page await program.navigateBack() expect(num).toBe(2) + // 新增 navigator 元素 + const elementNavigatorButton = await page.$('.navigatorButton') + await elementNavigatorButton.tap() + await page.waitFor(300) + + const currentPage = await program.currentPage() + expect(currentPage.path).toBe('pages/API/interceptor/page2') + await program.navigateBack() }) it('removeInterceptor', async () => { @@ -31,5 +47,13 @@ describe('interceptor', () => { const num = (await newPage.data()).page await program.navigateBack() expect(num).toBe(1) + // 新增 navigator 元素 + const elementNavigatorButton = await page.$('.navigatorButton') + await elementNavigatorButton.tap() + await page.waitFor(300) + + const currentPage = await program.currentPage() + expect(currentPage.path).toBe('pages/API/interceptor/page1') + await program.navigateBack() }) -}) \ No newline at end of file +}) diff --git a/pages/API/interceptor/interceptor.uvue b/pages/API/interceptor/interceptor.uvue index aea6a613..78d0b228 100644 --- a/pages/API/interceptor/interceptor.uvue +++ b/pages/API/interceptor/interceptor.uvue @@ -4,7 +4,7 @@ 点击下方按钮{{msg}} - + -- GitLab