onLoad.test.js 4.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
jest.setTimeout(20000);
const PAGE_PATH = "/pages/API/navigator/new-page/onLoad";
const INTERMEDIATE_PAGE_PATH = "/pages/API/navigator/new-page/new-page-1";
const TARGET_PAGE_PATH = "/pages/API/navigator/new-page/new-page-2";
let page;

describe("onLoad", () => {
  it("adjustData", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
    await page.waitFor(500);
    await page.callMethod("navigateToOnLoadWithType", "adjustData");
    await page.waitFor(1000);
    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");
  // });
  // 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(500);
  //   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(500);
  //   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(500);
  //   await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
  //   await page.waitFor(1000);
  //   const image = await program.screenshot();
  //   expect(image).toMatchImageSnapshot();
  // });
});