From 3efb4a5feb19dfcb707e5d0ea338fce2c7fe3f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Fri, 10 May 2024 13:40:46 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0appBaseInfo=E3=80=81s?= =?UTF-8?q?ystemInfo=E5=BF=85=E5=A4=87=E5=B1=9E=E6=80=A7=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-app-base-info.test.js | 22 ++++++++++++++++++- .../get-system-info/get-system-info.test.js | 22 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/pages/API/get-app-base-info/get-app-base-info.test.js b/pages/API/get-app-base-info/get-app-base-info.test.js index 2a446c6c..a47c21f6 100644 --- a/pages/API/get-app-base-info/get-app-base-info.test.js +++ b/pages/API/get-app-base-info/get-app-base-info.test.js @@ -10,6 +10,16 @@ describe('ExtApi-GetAppBaseInfo', () => { ] const numberProperties = [ 'uniCompilerVersionCode', 'uniRuntimeVersionCode' + ] + const booleanProperties = [ + 'isUniAppX' + ] + const requiredProperties = [ + 'uniCompilerVersion', + 'uniCompilerVersionCode', + 'uniRuntimeVersion', + 'uniRuntimeVersionCode', + 'isUniAppX' ] beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -28,6 +38,16 @@ describe('ExtApi-GetAppBaseInfo', () => { expect(value).not.toBeNull(); expect(value).toBeGreaterThanOrEqual(3.90); } + if (booleanProperties.indexOf(key) != -1) { + expect(value).not.toBeNull(); + expect(typeof value).toBe('boolean'); + } } - }); + }); + 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`) + } + }) }); diff --git a/pages/API/get-system-info/get-system-info.test.js b/pages/API/get-system-info/get-system-info.test.js index 6f117c57..888aa8cd 100644 --- a/pages/API/get-system-info/get-system-info.test.js +++ b/pages/API/get-system-info/get-system-info.test.js @@ -15,6 +15,16 @@ describe('ExtApi-GetSystemInfo', () => { 'windowWidth', 'windowHeight', 'windowTop', 'windowBottom', 'screenTop', 'uniCompilerVersionCode', 'uniRuntimeVersionCode' + ] + const booleanProperties = [ + 'isUniAppX' + ] + const requiredProperties = [ + 'uniCompilerVersion', + 'uniCompilerVersionCode', + 'uniRuntimeVersion', + 'uniRuntimeVersionCode', + 'isUniAppX' ] beforeAll(async () => { @@ -34,6 +44,10 @@ describe('ExtApi-GetSystemInfo', () => { expect(value).not.toBeNull(); expect(value).toBeGreaterThanOrEqual(0); } + if (booleanProperties.indexOf(key) != -1) { + expect(value).not.toBeNull(); + expect(typeof value).toBe('boolean'); + } if (key == 'deviceOrientation') { expect(['portrait', 'landscape']).toContain(value); } @@ -41,5 +55,11 @@ describe('ExtApi-GetSystemInfo', () => { expect(['light', 'dark']).toContain(value); } } - }); + }); + 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`) + } + }) }); -- GitLab