提交 521ba91e 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

feat: 添加 onLaunch/onShow 相关测试

上级 4a566e93
......@@ -20,9 +20,17 @@
myMap: new Map<string, any>(),
func: () : string => {
return 'globalData func'
}
},
onLaunch: function () {
launchOptions: {
path: '',
} as OnLaunchOptions,
onShowOption: {
path: ''
} as OnShowOptions
},
onLaunch: function (res : OnLaunchOptions) {
this.globalData.launchOptions = res
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1000)
console.log('App Launch')
......@@ -38,7 +46,9 @@
// entryTypes: ['render', 'navigation'],
// } as PerformanceObserverOptions)
},
onShow: function () {
onShow: function (res : OnShowOptions) {
this.globalData.onShowOption = res
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App Show')
......@@ -83,12 +93,15 @@
<style>
/*每个页面公共css */
@import "./common/uni.css";
/* #ifdef WEB */
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
}
.uni-app--showleftwindow .uni-page-head-btn {
display: none !important;
}
/* #endif */
</style>
......@@ -8,4 +8,16 @@ describe('getLaunchOptionsSync', () => {
const data = await page.data()
expect(data.checked).toBe(true)
})
it('app onLaunch 和 getLaunchOptionsSync 结果一致', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
const res = await page.callMethod('compareOnLaunchRes')
expect(res.appOnLaunch).toEqual(res.launchOptions)
})
it('app onShow 和 getEnterOptionsSync 结果一致', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
const res = await page.callMethod('compareOnShowRes')
expect(res.appOnShow).toEqual(res.onShowOption)
})
})
......@@ -20,6 +20,27 @@ export default {
}
},
methods: {
// 自动化测试
compareOnLaunchRes() {
const launchOptions = uni.getLaunchOptionsSync();
const app = getApp()
const appOnLaunch = app.globalData.launchOptions;
return {
appOnLaunch,
launchOptions
}
},
compareOnShowRes() {
const onShowOption = uni.getEnterOptionsSync();
const app = getApp()
const appOnShow = app.globalData.onShowOption
return {
appOnShow,
onShowOption
}
},
getLaunchOptionsSync() {
const launchOptions = uni.getLaunchOptionsSync()
this.launchOptionsPath = launchOptions.path
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册