get-battery-info.test.js 582 字节
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
const PAGE_PATH = '/pages/API/get-battery-info/get-battery-info'

describe('ExtApi-GetBatteryInfo', () => {

  let page;
  let res;
 
  const numberProperties = [
    'level'
  ]
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(600);
    res = await uni.getBatteryInfo();
  });

  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);
      }
    }
  });
});