From a790ac23c6337eae18ba4ce36e0676bcfa63d3a9 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Wed, 15 Nov 2023 17:38:09 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=20onLoad=20=E7=94=9F?= =?UTF-8?q?=E5=91=BD=E5=91=A8=E6=9C=9F=E8=B0=83=E7=94=A8=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=20API=20=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/navigator/new-page/onLoad.test.js | 80 ++++++++++----------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/pages/API/navigator/new-page/onLoad.test.js b/pages/API/navigator/new-page/onLoad.test.js index 7708452b..2a214292 100644 --- a/pages/API/navigator/new-page/onLoad.test.js +++ b/pages/API/navigator/new-page/onLoad.test.js @@ -9,7 +9,7 @@ describe("onLoad", () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "adjustData"); - await page.waitFor(500); + await page.waitFor(100); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); @@ -17,7 +17,7 @@ describe("onLoad", () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "navigateTo"); - await page.waitFor(500); + await page.waitFor(100); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); @@ -33,7 +33,7 @@ describe("onLoad", () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "redirectTo"); - await page.waitFor(500); + await page.waitFor(100); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); @@ -41,7 +41,7 @@ describe("onLoad", () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "reLaunch"); - await page.waitFor(500); + await page.waitFor(100); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); @@ -50,44 +50,40 @@ describe("onLoad", () => { await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "switchTab"); page = await program.currentPage(); - await page.waitFor('view'); + await page.waitFor(100); expect(page.path).toBe("pages/tabBar/component"); }); - // toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面) - // 当 navigateTo 到 onLoad 页面时,toast 会被关闭 - // it("showToast", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "showToast"); - // await page.waitFor(1000); - // const image = await program.screenshot(); - // expect(image).toMatchImageSnapshot(); - // }); - // 同 toast - // it("showLoading", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor('view'); - // await page.callMethod("navigateToOnLoadWithType", "showLoading"); - // await page.waitFor(1000); - // const image = await program.screenshot(); - // expect(image).toMatchImageSnapshot(); - // }); - // 同 toast - // it("showModal", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor('view'); - // await page.callMethod("navigateToOnLoadWithType", "showModal"); - // await page.waitFor(1000); - // const image = await program.screenshot(); - // expect(image).toMatchImageSnapshot(); - // }); - // 同 toast - // it("showActionSheet", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor('view'); - // await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); - // await page.waitFor(1000); - // const image = await program.screenshot(); - // expect(image).toMatchImageSnapshot(); - // }); + it("showToast", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor('view'); + await page.callMethod("navigateToOnLoadWithType", "showToast"); + await page.waitFor(500); + const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); + expect(image).toMatchImageSnapshot(); + await page.waitFor('view'); + }); + it("showLoading", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor('view'); + await page.callMethod("navigateToOnLoadWithType", "showLoading"); + await page.waitFor(500); + const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); + expect(image).toMatchImageSnapshot(); + }); + it("showModal", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor('view'); + await page.callMethod("navigateToOnLoadWithType", "showModal"); + await page.waitFor(500); + const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); + expect(image).toMatchImageSnapshot(); + }); + it("showActionSheet", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor('view'); + await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); + await page.waitFor(500); + const image = await program.screenshot({adb: true, area: {x: 0, y: 200}}); + expect(image).toMatchImageSnapshot(); + }); }); -- GitLab