提交 280ad5d7 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io 提交者: 雪洛

test: uni.getSystemInfo增加测试例

上级 ef91cf75
...@@ -63,4 +63,10 @@ describe('ExtApi-GetSystemInfo', () => { ...@@ -63,4 +63,10 @@ describe('ExtApi-GetSystemInfo', () => {
expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`) 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)
})
}); });
...@@ -38,15 +38,23 @@ ...@@ -38,15 +38,23 @@
label : string, label : string,
value : string, value : string,
} }
const globalScreenHeight = uni.getSystemInfoSync().screenHeight
export default { export default {
data() { data() {
return { return {
title: 'getSystemInfo', title: 'getSystemInfo',
items: [] as Item[], items: [] as Item[],
screenHeightAtReady: 0,
jest_result: false,
} }
}, },
onUnload: function () { onUnload: function () {
}, },
onReady() {
this.screenHeightAtReady = uni.getSystemInfoSync().screenHeight
console.log(`全局获取屏幕高度: ${globalScreenHeight} onReady内获取屏幕高度: ${this.screenHeightAtReady}`);
},
methods: { methods: {
getSystemInfo: function () { getSystemInfo: function () {
uni.getSystemInfo({ uni.getSystemInfo({
...@@ -97,6 +105,9 @@ ...@@ -97,6 +105,9 @@
jest_getSystemInfo() : GetSystemInfoResult { jest_getSystemInfo() : GetSystemInfoResult {
return uni.getSystemInfoSync(); return uni.getSystemInfoSync();
}, },
jest_getScreenHeight_at_different_stages(){
this.jest_result = (globalScreenHeight == this.screenHeightAtReady)
}
} }
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册