scroll-view-refresher.test.js 2.3 KB
Newer Older
1 2
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/

雪洛's avatar
雪洛 已提交
3 4 5 6 7 8 9 10 11 12 13
describe('component-native-scroll-view-refresher', () => {
  if (!process.env.uniTestPlatformInfo.startsWith('android') && !process.env.uniTestPlatformInfo.startsWith('web') || process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
    it('other platform', () => {
      expect(1).toBe(1)
    })
    return
  }
  let page;
  beforeAll(async () => {
    page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher');
    await page.waitFor(300);
14
  });
15

雪洛's avatar
雪洛 已提交
16 17 18 19
  it('scroll-view-refresher-screenshot', async () => {
    //禁止滚动条
    await page.setData({
        showScrollbar: false
20
    })
雪洛's avatar
雪洛 已提交
21 22 23 24
    await page.waitFor(300);
    const image = await program.screenshot({fullPage: true});
    expect(image).toSaveImageSnapshot();
  })
25

26
  it('check_refresher_refresh_event', async () => {
雪洛's avatar
雪洛 已提交
27 28
    await page.setData({
      refresherTriggered: true
29
    })
30
    await page.waitFor(2000);
31 32 33
    expect(await page.data('refresherrefreshTimes')).toBe(1)
    // 手动设置下拉刷新状态refresher-triggered为true时,在web和iOS不触发@refresherpulling事件
    if(process.env.uniTestPlatformInfo.startsWith('android')){
34
      expect(await page.data('onRefresherpullingTest')).toBe('refresherpulling:Success')
35
      expect(await page.data('refresherrefreshTest')).toBe('refresherrefresh:Success')
36 37
    }
    await page.waitFor(1000);
38
    expect(await page.data('onRefresherrestoreTest')).toBe('refresherrestore:Success')
雪洛's avatar
雪洛 已提交
39
  });
40 41 42 43 44 45 46 47 48 49

  // 仅App端支持手势下拉刷新
  if(!process.env.uniTestPlatformInfo.startsWith('web')){
    it('check_refresherabort', async () => {
      await program.swipe({
        startPoint: {x: 100,y: 500},
        endPoint: {x: 100,y: 630},
        duration: 1000
      })
      await page.waitFor(1500)
50 51 52 53
      // 下拉刷新被中止,在iOS不触发@refresherabort事件
      if(process.env.UNI_UTS_PLATFORM.startsWith('app-android')){
        expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success')
      }
54 55
    });
  }
雪洛's avatar
雪洛 已提交
56 57 58 59 60 61 62 63 64

  it('check_refresher_snapshot', async () => {
    await page.setData({
      refresherTriggered: true
    })
    await page.waitFor(300);
    const image = await program.screenshot({fullPage: true});
    expect(image).toSaveImageSnapshot();
  });
65
});