提交 540bf4ce 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test(api): page lifecycle

上级 b2112866
......@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/load-font-face/load-font-face'
describe('loadFontFace', () => {
beforeAll(async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(2000)
await page.waitFor(3000)
})
it('screenshot', async () => {
const image = await program.screenshot()
......
......@@ -28,45 +28,49 @@ describe('page-lifecycle', () => {
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(120)
await page.callMethod('setLifeCycleNum', 0)
})
it('onPullDownRefresh', async () => {
await page.callMethod('pullDownRefresh')
await page.waitFor(1500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(130)
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
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(140)
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
it('onHide', async () => {
page = await program.navigateTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(130)
expect(lifeCycleNum).toBe(-10)
page = await program.navigateBack()
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(140)
expect(lifeCycleNum).toBe(0)
})
it('onUnload', async () => {
page = await program.redirectTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(40)
expect(lifeCycleNum).toBe(-100)
await page.callMethod('setLifeCycleNum', 0)
})
it('onBackPress', async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(160)
expect(lifeCycleNum).toBe(120)
page = await program.navigateBack()
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(50)
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册