From 3f6b40f32e431572c6810ae0e4dd19b3558559d4 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sat, 5 Aug 2023 15:11:47 +0800 Subject: [PATCH] test: navigator --- pages/API/navigator/new-page/new-page-2.test.js | 13 ++++++------- pages/API/navigator/new-page/new-page-2.uvue | 6 ++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pages/API/navigator/new-page/new-page-2.test.js b/pages/API/navigator/new-page/new-page-2.test.js index 45cff1a3..3d02a812 100644 --- a/pages/API/navigator/new-page/new-page-2.test.js +++ b/pages/API/navigator/new-page/new-page-2.test.js @@ -35,39 +35,38 @@ describe('page-lifecycle', () => { lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(130) }) - // TODO: pageScrollTo 无法触发 onReachBottom, 待修复后调整 lifeCycleNum it('onPageScroll onReachBottom', async () => { await program.pageScrollTo(2000) const data = await page.data() expect(data.isScrolled).toBe(true) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(130) + expect(lifeCycleNum).toBe(140) }) it('onHide', async () => { page = await program.navigateTo(INTERMEDIATE_PAGE_PATH) await page.waitFor(1000) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(120) + expect(lifeCycleNum).toBe(130) page = await program.navigateBack() await page.waitFor(1000) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(130) + expect(lifeCycleNum).toBe(140) }) it('onUnload', async () => { page = await program.redirectTo(INTERMEDIATE_PAGE_PATH) await page.waitFor(1000) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(30) + expect(lifeCycleNum).toBe(40) }) it('onBackPress', async () => { page = await program.navigateTo(PAGE_PATH) await page.waitFor(1000) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(150) + expect(lifeCycleNum).toBe(160) page = await program.navigateBack() await page.waitFor(1000) lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(40) + expect(lifeCycleNum).toBe(50) await page.callMethod('setLifeCycleNum', 0) }) }) diff --git a/pages/API/navigator/new-page/new-page-2.uvue b/pages/API/navigator/new-page/new-page-2.uvue index 02fb0b48..728934ea 100644 --- a/pages/API/navigator/new-page/new-page-2.uvue +++ b/pages/API/navigator/new-page/new-page-2.uvue @@ -1,7 +1,7 @@ @@ -26,7 +26,6 @@ export default { setLifeCycleNum(state.lifeCycleNum + 10) }, onPullDownRefresh() { - console.log('onPullDownRefresh') // 自动化测试 setLifeCycleNum(state.lifeCycleNum + 10) }, @@ -35,7 +34,6 @@ export default { this.isScrolled = true }, onReachBottom() { - console.log('onReachBottom') // 自动化测试 setLifeCycleNum(state.lifeCycleNum + 10) }, @@ -70,7 +68,7 @@ export default { }, }) }, - pageScrollTo() { + scrollToBottom() { uni.pageScrollTo({ scrollTop: 2000, }) -- GitLab