提交 21e5f843 编写于 作者: H hdx

getEnterOptionsSync: 简化示例,移除一些不必要的逻辑

上级 46afa092
const PAGE_PATH = '/pages/API/get-enter-options-sync/get-enter-options-sync'
describe('getEnterOptionsSync', () => {
it('getEnterOptionsSync', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
await page.callMethod('getEnterOptionsSync')
const data = await page.data()
expect(data.checked).toBe(true)
})
it('app onShow 和 getEnterOptionsSync 结果一致', async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
const res = await page.callMethod('compareOnShowRes')
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('android')) {
// if android return
expect(true).toBe(true)
}
expect(res.appOnShow).toEqual(res.onShowOption)
const pageData = await page.data()
expect(pageData.testResult).toBe(true)
})
})
<template>
<page-head title="getEnterOptionsSync"></page-head>
<view class="uni-padding-wrap">
<button @click="getEnterOptionsSync">getEnterOptionsSync</button>
<view v-if="enterOptionsPath.length > 0" class="uni-common-mt">
<text>应用启动路径:</text>
<text style="margin-top: 5px">{{ EnterOptionsPath }}</text>
<view class="uni-common-mt">
<text>应用本次启动路径:</text>
<text style="margin-top: 5px">{{ enterOptionsString }}</text>
</view>
</view>
</template>
<script lang="uts">
type OnShowReturn = {
appOnShow : OnShowOptions,
onShowOption : OnShowOptions
}
<script>
export default {
data() {
return {
checked: false,
homePagePath: 'pages/tabBar/component',
enterOptionsPath: '' }
},
methods: {
// 自动化测试
compareOnShowRes() : OnShowReturn {
// #ifdef APP-ANDROID
const res : OnShowReturn = {
appOnShow: {
path: ''
} as OnShowOptions,
onShowOption: {
path: ''
} as OnShowOptions
}
return res
// #endif
// #ifndef APP-ANDROID
const onShowOption = uni.getEnterOptionsSync();
const app = getApp()
const appOnShow = app.globalData.onShowOption as OnShowOptions
return {
appOnShow,
onShowOption
}
// #endif
},
getEnterOptionsSync() {
const enterOptions = uni.getEnterOptionsSync()
this.enterOptionsPath = enterOptions.path
if (enterOptions.path == this.homePagePath) {
this.checked = true
}
},
},
return {
enterOptionsString: '',
testResult: false }
},
onReady() {
const app = getApp()
const appOnShow = app.globalData.onShowOption
const onShowOption = uni.getEnterOptionsSync()
this.enterOptionsString = JSON.stringify(onShowOption, null, 2)
this.testResult = (onShowOption.path == appOnShow.path && onShowOption.appScheme == appOnShow.appScheme && onShowOption.appLink == appOnShow.appLink)
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册