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 9cc4c2da4c0ba1992d4c6847eabe66ced211aa81..6b340e3198d93ba2a4d0ab77c13e6fa75b171066 100644 --- a/pages/API/get-system-info/get-system-info.test.js +++ b/pages/API/get-system-info/get-system-info.test.js @@ -63,4 +63,10 @@ describe('ExtApi-GetSystemInfo', () => { expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`) } }) + + it('Check screenHeight at different stages', async ()=> { + await page.callMethod('jest_getScreenHeight_at_different_stages') + res = await page.data('jest_result'); + expect(res).toBe(true) + }) }); diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index f1115d1dfc7bf3264d5a23ab1a0d1abf6ac8dfe0..022c54d58170858ff4f2312d7775f93532578f67 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -37,15 +37,23 @@ type Item = { label : string, value : string, - } + } + const globalScreenHeight = uni.getSystemInfoSync().screenHeight export default { data() { return { title: 'getSystemInfo', - items: [] as Item[], + items: [] as Item[], + screenHeightAtReady: 0, + jest_result: false, } }, onUnload: function () { + }, + + onReady() { + this.screenHeightAtReady = uni.getSystemInfoSync().screenHeight + console.log(`全局获取屏幕高度: ${globalScreenHeight} onReady内获取屏幕高度: ${this.screenHeightAtReady}`); }, methods: { getSystemInfo: function () { @@ -96,7 +104,10 @@ //自动化测试例专用 jest_getSystemInfo() : GetSystemInfoResult { return uni.getSystemInfoSync(); - }, + }, + jest_getScreenHeight_at_different_stages(){ + this.jest_result = (globalScreenHeight == this.screenHeightAtReady) + } } }