swiper2.test.js 1015 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
const PAGE_PATH = '/pages/component/swiper/swiper'
2

DCloud-WZF's avatar
DCloud-WZF 已提交
3 4 5 6
describe('swiper-touch-test', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isWeb = platformInfo.startsWith('web')
DCloud-WZF's avatar
DCloud-WZF 已提交
7 8 9 10
const isMP = platformInfo.startsWith('mp')
  // 屏蔽 web * android 平台, 需要针对调整坐标
  // 屏蔽 小程序,不支持 program.swipe
  if (isWeb || isAndroid || isMp) {
11 12 13 14 15
    it('other platform', () => {
      expect(1).toBe(1)
    })
    return
  }
DCloud-WZF's avatar
DCloud-WZF 已提交
16 17 18 19 20 21

  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(1500);
  })
22 23 24 25


  it('swiper-touch-test', async () => {

26 27 28
    let x = await page.data('swipeX')
    let y = await page.data('swipeY')

29
    await program.swipe({
30 31
      startPoint: {x: x,y: y},
      endPoint: {x: 10,y: y},
32 33 34 35 36 37 38 39
      duration: 200
    })

    await page.waitFor(1000)
    let val = await page.data('currentValChange')
    console.log(val)
    expect(val).toEqual(1)
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
40

41
})