From 22d6befc7eb1ad861c26864e85b96f19a6d60c7e Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sun, 8 Oct 2023 17:39:48 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=94=BE=E5=BC=80=20onLoad=20=E7=94=9F?= =?UTF-8?q?=E5=91=BD=E5=91=A8=E6=9C=9F=E8=B7=AF=E7=94=B1=20API=20=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/navigator/new-page/onLoad.test.js | 85 ++++++++++----------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/pages/API/navigator/new-page/onLoad.test.js b/pages/API/navigator/new-page/onLoad.test.js index 8edf7b24..853d8d27 100644 --- a/pages/API/navigator/new-page/onLoad.test.js +++ b/pages/API/navigator/new-page/onLoad.test.js @@ -13,51 +13,46 @@ describe("onLoad", () => { const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); - // 先出现 TARGET_PAGE_PATH 页面,再出现 onLoad 页面, 顺序异常 - // it("navigateTo", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "navigateTo"); - // await page.waitFor(1000); - // page = await program.currentPage(); - // expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); - // }); - // 页面白屏 - // it("navigateBack", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "navigateBack"); - // await page.waitFor(1000); - // page = await program.currentPage(); - // expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); - // }); - // 直接出现 TARGET_PAGE_PATH 页面,又动画了 TARGET_PAGE_PATH 页面 - // it("redirectTo", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "redirectTo"); - // await page.waitFor(1000); - // page = await program.currentPage(); - // expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); - // }); - // 直接出现 TARGET_PAGE_PATH 页面,又动画了 TARGET_PAGE_PATH 页面 - // it("reLaunch", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "reLaunch"); - // await page.waitFor(1000); - // page = await program.currentPage(); - // expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); - // }); - // 页面白屏 - // it("switchTab", async () => { - // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); - // await page.callMethod("navigateToOnLoadWithType", "switchTab"); - // await page.waitFor(1000); - // page = await program.currentPage(); - // expect(page.path).toBe("pages/tabBar/component"); - // }); + it("navigateTo", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor(500); + await page.callMethod("navigateToOnLoadWithType", "navigateTo"); + await page.waitFor(1000); + page = await program.currentPage(); + expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); + }); + it("navigateBack", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor(500); + await page.callMethod("navigateToOnLoadWithType", "navigateBack"); + await page.waitFor(1000); + page = await program.currentPage(); + expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1)); + }); + it("redirectTo", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor(500); + await page.callMethod("navigateToOnLoadWithType", "redirectTo"); + await page.waitFor(1000); + page = await program.currentPage(); + expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); + }); + it("reLaunch", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor(500); + await page.callMethod("navigateToOnLoadWithType", "reLaunch"); + await page.waitFor(1000); + page = await program.currentPage(); + expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); + }); + it("switchTab", async () => { + page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); + await page.waitFor(500); + await page.callMethod("navigateToOnLoadWithType", "switchTab"); + await page.waitFor(1000); + page = await program.currentPage(); + expect(page.path).toBe("pages/tabBar/component"); + }); // toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面) // 当 navigateTo 到 onLoad 页面时,toast 会被关闭 // it("showToast", async () => { -- GitLab