get-system-info.test.js 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9
const PAGE_PATH = '/pages/API/get-system-info/get-system-info'

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

  let page;
  let res;
  const stringProperties = [
    'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode',
    'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language',
10
    'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion',
11 12 13 14 15 16
    'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion',
  ]
  const numberProperties = [
    'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
    'windowWidth',
    'windowHeight', 'windowTop', 'windowBottom', 'screenTop',
17 18 19 20 21 22 23
    'uniCompileVersionCode', 'uniRuntimeVersionCode'
  ]


  if (process.env.uniTestPlatformInfo.indexOf('web') === -1) {
    stringProperties.push('version')
  }
24 25 26 27 28 29 30 31 32

  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(600);
    res = await page.callMethod('jest_getSystemInfo')
  });
  it('Check GetSystemInfoSync', async () => {
    for (const key in res) {
      const value = res[key];
33
      console.log("key :",key , "value :", value);
34
      if (stringProperties.indexOf(key) != -1) {
35
        expect(value).not.toBeNull();
36 37 38
        expect(value).not.toBe("");
      }
      if (numberProperties.indexOf(key) != -1) {
39
        expect(value).not.toBeNull();
40 41 42 43 44 45 46
        expect(value).toBeGreaterThanOrEqual(0);
      }
      if (key == 'deviceOrientation') {
        expect(['portrait', 'landscape']).toContain(value);
      }
    }
  });
47
});