get-battery-info.test.js 853 字节
Newer Older
1 2 3
const PAGE_PATH = '/pages/API/get-battery-info/get-battery-info'

describe('ExtApi-GetBatteryInfo', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8 9
  if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }
lizhongyi_'s avatar
lizhongyi_ 已提交
10 11 12 13 14 15
  if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
    it('dummyTest', () => {
      expect(1).toBe(1)
    })
    return
  }
杜庆泉's avatar
杜庆泉 已提交
16

17 18
  let page;
  let res;
雪洛's avatar
雪洛 已提交
19

20 21 22 23 24 25
  const numberProperties = [
    'level'
  ]
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(600);
杜庆泉's avatar
杜庆泉 已提交
26
    res = await page.data();
27 28 29 30 31 32 33 34 35 36 37 38
  });

  it('Check properties', async () => {
    for (const key in res) {
      const value = res[key];
      expect(value).not.toBeNull();
      if (numberProperties.indexOf(key) != -1) {
        expect(value).toBeGreaterThanOrEqual(0.1);
      }
    }
  });
});