提交 55d552d9 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: navigator

上级 06825729
jest.setTimeout(40000)
jest.setTimeout(80000)
const CURRENT_PAGE_PATH = '/pages/API/navigator/navigator'
const CHILD1_PAGE_PATH = '/pages/API/navigator/new-page/new-page-1'
const CHILD2_PAGE_PATH = '/pages/API/navigator/new-page/new-page-2'
......@@ -140,6 +140,7 @@ describe('navigator', () => {
})
it('switchTab', async () => {
page = await program.reLaunch(CURRENT_PAGE_PATH)
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('switchTab')
await page.waitFor(500)
......@@ -148,4 +149,50 @@ describe('navigator', () => {
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('20 times navigateTo', async () => {
const originPageStack = await program.pageStack()
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
const newPageStack = await program.pageStack()
expect(newPageStack.length - originPageStack.length).toBe(20)
})
})
......@@ -39,9 +39,6 @@
<button @tap="reLaunch" class="uni-btn">
关闭所有页面,打开首页
</button>
<button @tap="customAnimation" class="uni-btn">
使用自定义动画打开页面
</button>
<button @tap="navigateToErrorPage" class="uni-btn">
打开不存在的页面
</button>
......@@ -346,13 +343,6 @@ export default {
},
})
},
customAnimation() {
uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-1?data=自定义动画打开页面',
animationType: 'slide-in-bottom',
animationDuration: 200,
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册