get-device-info.test.js 968 B

12345678910111213141516171819202122232425262728293031
  1. const PAGE_PATH = '/pages/API/get-device-info/get-device-info'
  2. describe('ExtApi-GetDeviceInfo', () => {
  3. let page;
  4. let res;
  5. const stringProperties = [
  6. 'brand', 'deviceBrand', 'deviceId', 'model', 'deviceModel',
  7. 'deviceType', 'devicePixelRatio', 'system', 'platform', 'uniRuntimeVersion',
  8. 'osName', 'osVersion', 'osLanguage', 'osTheme', 'romName', 'romVersion'
  9. ]
  10. beforeAll(async () => {
  11. page = await program.reLaunch(PAGE_PATH)
  12. await page.waitFor(600);
  13. res = await uni.getDeviceInfo();
  14. });
  15. it('Check properties', async () => {
  16. for (const key in res) {
  17. const value = res[key];
  18. console.log("key :",key , "value :", value);
  19. if (stringProperties.indexOf(key) != -1) {
  20. expect(value).not.toBeNull();
  21. expect(value).not.toBe("");
  22. }
  23. if (key == 'deviceOrientation') {
  24. expect(value).not.toBeNull();
  25. expect(['portrait', 'landscape']).toContain(value);
  26. }
  27. }
  28. });
  29. });