set-navigation-bar-title.test.js 1.2 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4
const CURRENT_PAGE_PATH =
  "/pages/API/set-navigation-bar-title/set-navigation-bar-title";

describe("setNavigationBarColor", () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
5 6 7 8 9 10
  if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }
DCloud-WZF's avatar
DCloud-WZF 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24
  let page;
  let originLifeCycleNum;
  beforeAll(async () => {
    page = await program.navigateTo(CURRENT_PAGE_PATH);
    await page.waitFor(1000);
    originLifeCycleNum = await page.callMethod("getLifeCycleNum");
  });

  afterAll(async () => {
    await page.callMethod("setLifeCycleNum", originLifeCycleNum);
    const lifeCycleNum = await page.callMethod("getLifeCycleNum");
    expect(lifeCycleNum).toBe(originLifeCycleNum);
  });

25 26
  it("setNavigationBarNewTitle", async () => {
    await page.callMethod("setNavigationBarNewTitle");
DCloud-WZF's avatar
DCloud-WZF 已提交
27
    const image = await program.screenshot();
28
    expect(image).toSaveImageSnapshot();
DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31
    const lifeCycleNum = await page.callMethod("getLifeCycleNum");
    expect(lifeCycleNum - originLifeCycleNum).toBe(2);
  });
32 33 34
  it("setNavigationBarLongTitle", async () => {
    await page.callMethod("setNavigationBarLongTitle");
    const image = await program.screenshot();
35
    expect(image).toSaveImageSnapshot();
36
  });
DCloud-WZF's avatar
DCloud-WZF 已提交
37
});