提交 0afab4b3 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(getCurrentPages): 补充 UniPage 方法示例及测试

上级 bc471191
...@@ -2,6 +2,7 @@ const HOME_PAGE_PATH = '/pages/tabBar/component' ...@@ -2,6 +2,7 @@ const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123' const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android') const isAndroid = platformInfo.startsWith('android')
const isWeb = platformInfo.startsWith('web')
describe('getCurrentPages', () => { describe('getCurrentPages', () => {
let page let page
...@@ -100,4 +101,12 @@ describe('getCurrentPages', () => { ...@@ -100,4 +101,12 @@ describe('getCurrentPages', () => {
const res = await page.callMethod('checkGetAndroidView') const res = await page.callMethod('checkGetAndroidView')
expect(res).toBe(isAndroid) expect(res).toBe(isAndroid)
}) })
it('getIOSView', async () => {
const res = await page.callMethod('checkGetIOSView')
expect(res).toBe(false)
})
it('getHTMLElement', async () => {
const res = await page.callMethod('checkGetHTMLElement')
expect(res).toBe(isWeb)
})
}) })
...@@ -25,7 +25,13 @@ ...@@ -25,7 +25,13 @@
<button class="uni-common-mt" @click="checkGetAndroidView"> <button class="uni-common-mt" @click="checkGetAndroidView">
check getAndroidView check getAndroidView
</button> </button>
</view> <button class="uni-common-mt" @click="checkGetIOSView">
check getIOSView
</button>
<button class="uni-common-mt" @click="checkGetHTMLElement">
check getHTMLElement
</button>
</view>
<!-- #ifndef MP --> <!-- #ifndef MP -->
<page-head title="currentPageStyle"></page-head> <page-head title="currentPageStyle"></page-head>
<template v-for="(item, index) in PageStyleArray"> <template v-for="(item, index) in PageStyleArray">
...@@ -55,7 +61,7 @@ ...@@ -55,7 +61,7 @@
</template> </template>
<button style="margin: 10px" @click="goSetDisablePullDownRefresh"> <button style="margin: 10px" @click="goSetDisablePullDownRefresh">
go set disable pullDownRefresh go set disable pullDownRefresh
</button> </button>
<!-- #endif --> <!-- #endif -->
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -214,6 +220,22 @@ ...@@ -214,6 +220,22 @@
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' }) uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res return res
}, },
checkGetIOSView() : boolean {
const page = this.getCurrentPage()
const IOSView = page.getIOSView()
const res = IOSView != null
console.log('check getIOSView', res)
uni.showToast(res ? { title: 'check success' } : { title: '仅 IOS uts 插件环境支持', icon: 'error' })
return res
},
checkGetHTMLElement() : boolean {
const page = this.getCurrentPage()
const HTMLView = page.getHTMLElement()
const res = HTMLView != null
console.log('check getHTMLElement', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
}, },
} }
</script> </script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册