提交 7fb1f62b 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

feat: 补充 getEnterOptionsSync 页面

上级 2670aa79
...@@ -551,6 +551,13 @@ ...@@ -551,6 +551,13 @@
"navigationBarTitleText": "getLaunchOptionsSync | 获取启动参数" "navigationBarTitleText": "getLaunchOptionsSync | 获取启动参数"
} }
}, },
{
"path": "pages/API/get-enter-options-sync/get-enter-options-sync",
"group": "1,1,4,1",
"style": {
"navigationBarTitleText": "getEnterOptionsSync | 获取启动参数"
}
},
{ {
"path": "pages/API/navigator/navigator", "path": "pages/API/navigator/navigator",
"group": "1,2,0", "group": "1,2,0",
...@@ -2075,6 +2082,10 @@ ...@@ -2075,6 +2082,10 @@
{ {
"id": "api.base.launch.getLaunchOptionsSync", "id": "api.base.launch.getLaunchOptionsSync",
"name": "getLaunchOptionsSync" "name": "getLaunchOptionsSync"
},
{
"id": "api.base.launch.getEnterOptionsSync",
"name": "getLEnterOptionsSync"
} }
] ]
}, },
...@@ -2744,4 +2755,4 @@ ...@@ -2744,4 +2755,4 @@
] ]
} }
] ]
} }
\ No newline at end of file
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)
})
})
<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>
</view>
</template>
<script lang="uts">
type OnShowReturn = {
appOnShow : OnShowOptions,
onShowOption : OnShowOptions
}
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
}
},
},
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册