get-current-pages.test.js 843 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
const HOME_PAGE_PATH = '/pages/tabBar/component'
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'

describe('getCurrentPages', () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
5
  let page
DCloud-WZF's avatar
DCloud-WZF 已提交
6
  it('getCurrentPages', async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
7 8 9 10 11 12 13 14 15 16 17
    // web 端等待应用首页加载完成
    if (process.env.uniTestPlatformInfo.startsWith('web')) {
      const waitTime = process.env.uniTestPlatformInfo.includes('safari')
        ? 5000
        : 1000
      await new Promise((resolve) => {
        setTimeout(() => {
          resolve()
        }, waitTime)
      })
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
18 19
    page = await program.switchTab(HOME_PAGE_PATH)
    await page.waitFor(1000)
DCloud-WZF's avatar
DCloud-WZF 已提交
20
    page = await program.navigateTo(PAGE_PATH)
DCloud-WZF's avatar
DCloud-WZF 已提交
21
    await page.waitFor(1000)
DCloud-WZF's avatar
DCloud-WZF 已提交
22
    await page.callMethod('_getCurrentPages')
DCloud-WZF's avatar
DCloud-WZF 已提交
23
    await page.waitFor(200)
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26 27
    const data = await page.data()
    expect(data.checked).toBe(true)
  })
})