get-app-base-info.test.js 1.7 KB

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