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

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

  let page;
  let res;
  const stringProperties = [
    'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage',
DCloud_iOS_WZT's avatar
DCloud_iOS_WZT 已提交
9
    'language', 'uniCompilerVersion', 'uniPlatform', 'uniRuntimeVersion',
10 11
  ]
  const numberProperties = [
DCloud_iOS_WZT's avatar
DCloud_iOS_WZT 已提交
12
    'uniCompilerVersionCode', 'uniRuntimeVersionCode'
13 14 15 16 17 18 19 20 21 22
  ]
  const booleanProperties = [
    'isUniAppX'
  ]
  const requiredProperties = [
    'uniCompilerVersion',
    'uniCompilerVersionCode',
    'uniRuntimeVersion',
    'uniRuntimeVersionCode',
    'isUniAppX'
DCloud_iOS_WZT's avatar
DCloud_iOS_WZT 已提交
23
  ]
24 25 26 27 28 29 30
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(600);
    res = await uni.getAppBaseInfo();
  });
  it('Check properties', async () => {
    for (const key in res) {
31 32 33 34
      const value = res[key];
      console.log("key :",key , "value :", value);
      if (stringProperties.indexOf(key) != -1) {
        expect(value).not.toBeNull();
35 36
        expect(value).not.toBe("");
      }
37 38
      if (numberProperties.indexOf(key) != -1) {
        expect(value).not.toBeNull();
39 40
        expect(value).toBeGreaterThanOrEqual(3.90);
      }
41 42 43 44
      if (booleanProperties.indexOf(key) != -1) {
        expect(value).not.toBeNull();
        expect(typeof value).toBe('boolean');
      }
45
    }
46 47 48 49 50 51 52
  });
  it('Check GetSystemInfoSync required properties', async () => {
    for (let i = 0; i < requiredProperties.length; i++) {
      const key = requiredProperties[i]
      expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`)
    }
  })
53
});