onLoad.test.js 3.6 KB
Newer Older
1 2 3
jest.setTimeout(20000);
const PAGE_PATH = "/pages/API/navigator/new-page/onLoad";
const INTERMEDIATE_PAGE_PATH = "/pages/API/navigator/new-page/new-page-1";
4
const TARGET_PAGE_PATH = "/pages/API/navigator/new-page/new-page-3";
5 6 7 8 9
let page;

describe("onLoad", () => {
  it("adjustData", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
10
    await page.waitFor('view');
11
    await page.callMethod("navigateToOnLoadWithType", "adjustData");
12
    await page.waitFor(100);
13 14 15
    const image = await program.screenshot();
    expect(image).toMatchImageSnapshot();
  });
16 17
  it("navigateTo", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
18
    await page.waitFor('view');
19
    await page.callMethod("navigateToOnLoadWithType", "navigateTo");
20
    await page.waitFor(100);
21 22 23 24 25
    page = await program.currentPage();
    expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
  });
  it("navigateBack", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
26
    await page.waitFor('view');
27 28
    await page.callMethod("navigateToOnLoadWithType", "navigateBack");
    page = await program.currentPage();
29
    await page.waitFor('view');
30 31 32 33
    expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1));
  });
  it("redirectTo", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
34
    await page.waitFor('view');
35
    await page.callMethod("navigateToOnLoadWithType", "redirectTo");
36
    await page.waitFor(100);
37 38 39 40 41
    page = await program.currentPage();
    expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
  });
  it("reLaunch", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
42
    await page.waitFor('view');
43
    await page.callMethod("navigateToOnLoadWithType", "reLaunch");
44
    await page.waitFor(100);
45 46 47 48 49
    page = await program.currentPage();
    expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
  });
  it("switchTab", async () => {
    page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
50
    await page.waitFor('view');
51 52
    await page.callMethod("navigateToOnLoadWithType", "switchTab");
    page = await program.currentPage();
53
    await page.waitFor(100);
54 55
    expect(page.path).toBe("pages/tabBar/component");
  });
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
  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();
  });
89
});