get-current-pages.test.js 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'

describe('getCurrentPages', () => {
  let page
  it('getCurrentPages', async () => {
    // web 端等待应用首页加载完成
    if (process.env.uniTestPlatformInfo.startsWith('web')) {
      const waitTime = process.env.uniTestPlatformInfo.includes('safari') ?
        5000 :
        1000
      await new Promise((resolve) => {
        setTimeout(() => {
          resolve()
        }, waitTime)
      })
    }
    page = await program.switchTab(HOME_PAGE_PATH)
    await page.waitFor(1000)
    page = await program.navigateTo(PAGE_PATH)
    await page.waitFor(1000)
    await page.callMethod('_getCurrentPages')
    await page.waitFor(200)
    const data = await page.data()
    expect(data.checked).toBe(true)
  })
  it('getPageStyle', async () => {
    const btn = await page.$('.btn-get-page-style')
    await btn.tap()
    await page.waitFor(100)

    const {
      currentPageStyle
    } = await page.data()

    expect(currentPageStyle['enablePullDownRefresh']).toBe(true)
  })
  it('setPageStyle', async () => {
    const btn = await page.$('.btn-set-page-style-0')
    await btn.tap()
    await page.waitFor(100)

    const {
      currentPageStyle
    } = await page.data()

    expect(currentPageStyle['enablePullDownRefresh']).toBe(false)
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
49
})