theme-change.test.js 1.1 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1 2 3
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/

describe('API-theme-change', () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
4 5 6 7 8 9 10 11
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  const isIos = platformInfo.startsWith('ios')
  if (isIos) {
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }
shutao-dc's avatar
shutao-dc 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
  let page;
  const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";

  if (!isApp) {
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }

  beforeAll(async () => {
    page = await program.reLaunch('/pages/API/theme-change/theme-change')
    await page.waitFor(600);
  });



  it("check-set-app-theme", async () => {
30 31
    const originalTheme = await page.data('originalTheme')
    console.log("originalTheme是", originalTheme)
shutao-dc's avatar
shutao-dc 已提交
32 33 34
    await page.callMethod('setAppTheme', "dark")
    await page.waitFor(300)
    expect(await page.data('appTheme')).toBe("dark")
35
    //还原主题为light
36
    await page.callMethod('setAppTheme', originalTheme)
37
    await page.waitFor(600)
shutao-dc's avatar
shutao-dc 已提交
38 39
  })
});