get-window-info.test.js 1.0 KB
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
const PAGE_PATH = '/pages/API/get-window-info/get-window-info'

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

  let page;
  let res;
  const numberProperties = [
    'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
    'windowWidth',
    'windowHeight', 'windowTop', 'windowBottom', 'screenTop'
  ]

  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(600);
    res = await page.callMethod('jest_getWindowInfo')
  });

  it('Check GetWindowInfo', async () => {
    for (const key in res) {
      const value = res[key];
      expect(value).not.toBeNull();
      if (numberProperties.indexOf(key) != -1) {
        expect(value).toBeGreaterThanOrEqual(0);
      }
26 27 28 29 30 31 32
    }
    if (process.env.uniTestPlatformInfo.startsWith('android')) {
      if (res.safeAreaInsets.bottom > 0) {
        expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
      } else {
        expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
      }
33 34 35
    }
  });
});