set-page-style-disable-pull-down-refresh.test.js 2.0 KB
Newer Older
1 2 3
const PAGE_PATH = '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'

describe('getCurrentPages', () => {
4 5 6 7
  if (
    process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') ||
    process.env.uniTestPlatformInfo.startsWith('mp')
  ) {
雪洛's avatar
雪洛 已提交
8 9 10 11 12 13 14 15
    it('not-support', async () => {
      expect(1).toBe(1)
    })
    return
  }
  let page
  it('page-style', async () => {
    page = await program.navigateTo(PAGE_PATH)
16
    //onLoad会对currentPageStyle赋值
雪洛's avatar
雪洛 已提交
17
    await page.waitFor(200)
18 19
    const currentPageStyle = (await page.data()).currentPageStyle
    const isEnablePullDownRefresh1 = currentPageStyle.enablePullDownRefresh
雪洛's avatar
雪洛 已提交
20
    expect(isEnablePullDownRefresh1).toBe(false)
21 22
    //校验pageStyle数据是否完整
    expect(currentPageStyle.navigationStyle != undefined && currentPageStyle.onReachBottomDistance != undefined).toBe(true)
雪洛's avatar
雪洛 已提交
23 24 25 26 27 28 29 30 31 32 33 34

    await page.callMethod('setPageStyle', true)
    await page.waitFor(200)
    await page.callMethod('getPageStyle')
    await page.waitFor(200)
    const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh
    expect(isEnablePullDownRefresh2).toBe(true)
    await page.callMethod('startPullDownRefresh')
    await page.waitFor(500)
    const image3 = await program.screenshot({
      fullPage: true
    });
35 36 37
    expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() {
      return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-before-set-page-style'
    }});
雪洛's avatar
雪洛 已提交
38 39 40 41 42 43 44 45 46 47 48

    await page.waitFor(3500)

    // setPageStyle
    await page.callMethod('setPageStyle', false)
    await page.waitFor(200)
    await page.callMethod('startPullDownRefresh')
    await page.waitFor(500)
    const image2 = await program.screenshot({
      fullPage: true
    });
49 50 51
    expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() {
      return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-after-set-page-style'
    }});
雪洛's avatar
雪洛 已提交
52

53
  })
54
})