list-view-refresh.test.js 1.4 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1 2
describe('component-native-list-view-refresh', () => {
  if (process.env.uniTestPlatformInfo.startsWith('web')) {
3 4
    it('dummyTest', async () => {
      expect(1).toBe(1)
shutao-dc's avatar
shutao-dc 已提交
5 6
    })
    return
7
  }
8 9 10 11 12 13 14 15

  if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
    it('跳过横屏模式', () => {
      expect(1).toBe(1)
    })
    return
  }

16
  let page
shutao-dc's avatar
shutao-dc 已提交
17
  beforeAll(async () => {
18 19 20
    //打开list-view测试页
    page = await program.reLaunch('/pages/component/list-view/list-view-refresh')
    await page.waitFor(600)
shutao-dc's avatar
shutao-dc 已提交
21 22 23 24 25 26 27 28
  })

  it('check_list_view_refresh', async () => {
    await page.waitFor(async () => {
      return await page.data('refresherTriggered') === false;
    });
    //等待下拉刷新结束
    await page.waitFor(500)
29
    const image = await program.screenshot({fullPage: true});
30
    expect(image).toSaveImageSnapshot();
31 32 33 34
    expect(await page.data('onRefresherpullingTest')).toBe('refresherpulling:Success')
    expect(await page.data('refresherrefreshTest')).toBe('refresherrefresh:Success')
    await page.waitFor(1000);
    expect(await page.data('onRefresherrestoreTest')).toBe('refresherrestore:Success')
35
  })
36 37 38 39 40 41

  it('check_refresherabort', async () => {
    // 仅App端支持手势下拉刷新
    await program.swipe({
      startPoint: {x: 100,y: 400},
      endPoint: {x: 100,y: 500},
42
      duration: 100
43 44
    })
    await page.waitFor(1500)
45
    expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success')
46 47
  });

shutao-dc's avatar
shutao-dc 已提交
48
})