From d7bb3e1c8b4dc6a62f1853629b71c46ee69a1942 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 2 Nov 2023 17:46:17 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=8B=A6=E6=88=AA=E5=99=A8=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/interceptor/interceptor.test.js | 35 +++++++++++++++++++ pages/API/interceptor/page1.uvue | 42 +++++++++++------------ pages/API/interceptor/page2.uvue | 42 +++++++++++------------ 3 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 pages/API/interceptor/interceptor.test.js diff --git a/pages/API/interceptor/interceptor.test.js b/pages/API/interceptor/interceptor.test.js new file mode 100644 index 00000000..5006a8a6 --- /dev/null +++ b/pages/API/interceptor/interceptor.test.js @@ -0,0 +1,35 @@ +const PAGE_PATH = '/pages/API/interceptor/interceptor' + +describe('interceptor', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + + it('no Interceptor', async () => { + const newPage = await program.navigateTo('./page1') + await newPage.waitFor('text') + const num = (await newPage.data()).page + await program.navigateBack() + expect(num).toBe(1) + }) + + it('addInterceptor', async () => { + await page.callMethod('addInterceptor') + const newPage = await program.navigateTo('./page1') + await newPage.waitFor('text') + const num = (await newPage.data()).page + await program.navigateBack() + expect(num).toBe(2) + }) + + it('removeInterceptor', async () => { + await page.callMethod('removeInterceptor') + const newPage = await program.navigateTo('./page1') + await newPage.waitFor('text') + const num = (await newPage.data()).page + await program.navigateBack() + expect(num).toBe(1) + }) +}) \ No newline at end of file diff --git a/pages/API/interceptor/page1.uvue b/pages/API/interceptor/page1.uvue index aa01b473..76063882 100644 --- a/pages/API/interceptor/page1.uvue +++ b/pages/API/interceptor/page1.uvue @@ -1,22 +1,22 @@ - - - - - \ No newline at end of file diff --git a/pages/API/interceptor/page2.uvue b/pages/API/interceptor/page2.uvue index f75d1e6c..e97ad1f3 100644 --- a/pages/API/interceptor/page2.uvue +++ b/pages/API/interceptor/page2.uvue @@ -1,22 +1,22 @@ - - - - - \ No newline at end of file -- GitLab