提交 3f6b40f3 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: navigator

上级 95172cbc
...@@ -35,39 +35,38 @@ describe('page-lifecycle', () => { ...@@ -35,39 +35,38 @@ describe('page-lifecycle', () => {
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(130) expect(lifeCycleNum).toBe(130)
}) })
// TODO: pageScrollTo 无法触发 onReachBottom, 待修复后调整 lifeCycleNum
it('onPageScroll onReachBottom', async () => { it('onPageScroll onReachBottom', async () => {
await program.pageScrollTo(2000) await program.pageScrollTo(2000)
const data = await page.data() const data = await page.data()
expect(data.isScrolled).toBe(true) expect(data.isScrolled).toBe(true)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(130) expect(lifeCycleNum).toBe(140)
}) })
it('onHide', async () => { it('onHide', async () => {
page = await program.navigateTo(INTERMEDIATE_PAGE_PATH) page = await program.navigateTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000) await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(120) expect(lifeCycleNum).toBe(130)
page = await program.navigateBack() page = await program.navigateBack()
await page.waitFor(1000) await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(130) expect(lifeCycleNum).toBe(140)
}) })
it('onUnload', async () => { it('onUnload', async () => {
page = await program.redirectTo(INTERMEDIATE_PAGE_PATH) page = await program.redirectTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000) await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(30) expect(lifeCycleNum).toBe(40)
}) })
it('onBackPress', async () => { it('onBackPress', async () => {
page = await program.navigateTo(PAGE_PATH) page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000) await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(150) expect(lifeCycleNum).toBe(160)
page = await program.navigateBack() page = await program.navigateBack()
await page.waitFor(1000) await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum') lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(40) expect(lifeCycleNum).toBe(50)
await page.callMethod('setLifeCycleNum', 0) await page.callMethod('setLifeCycleNum', 0)
}) })
}) })
<template> <template>
<view class="uni-padding-wrap container"> <view class="uni-padding-wrap container">
<page-head title="new-page-2" /> <page-head title="new-page-2" />
<button @click="pageScrollTo">scrollToBottom</button> <button @click="scrollToBottom">scrollToBottom</button>
</view> </view>
</template> </template>
...@@ -26,7 +26,6 @@ export default { ...@@ -26,7 +26,6 @@ export default {
setLifeCycleNum(state.lifeCycleNum + 10) setLifeCycleNum(state.lifeCycleNum + 10)
}, },
onPullDownRefresh() { onPullDownRefresh() {
console.log('onPullDownRefresh')
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10) setLifeCycleNum(state.lifeCycleNum + 10)
}, },
...@@ -35,7 +34,6 @@ export default { ...@@ -35,7 +34,6 @@ export default {
this.isScrolled = true this.isScrolled = true
}, },
onReachBottom() { onReachBottom() {
console.log('onReachBottom')
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10) setLifeCycleNum(state.lifeCycleNum + 10)
}, },
...@@ -70,7 +68,7 @@ export default { ...@@ -70,7 +68,7 @@ export default {
}, },
}) })
}, },
pageScrollTo() { scrollToBottom() {
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: 2000, scrollTop: 2000,
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册