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

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

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

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

shutao-dc's avatar
shutao-dc 已提交
40 41 42
  it('check_refresherabort', async () => {
    //部分安卓设备需要延迟一段时间swipe才生效 此处暂时延迟1秒
    await page.waitFor(1000);
43 44 45 46
    // 仅App端支持手势下拉刷新
    await program.swipe({
      startPoint: {x: 100,y: 400},
      endPoint: {x: 100,y: 500},
47
      duration: 100
48 49
    })
    await page.waitFor(1500)
50
    expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success')
51 52
  });

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