touch-events-preventDefault.test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const PAGE_PATH = '/pages/component/global-events/touch-events-preventDefault'
  2. describe('touch-events-test', () => {
  3. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  4. const isMP = platformInfo.startsWith('mp')
  5. const isWeb = platformInfo.startsWith('web')
  6. if (isWeb || isMP) {
  7. it('other platform', () => {
  8. expect(1).toBe(1)
  9. })
  10. return
  11. }
  12. if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
  13. it('跳过横屏模式', () => {
  14. expect(1).toBe(1)
  15. })
  16. return
  17. }
  18. let page
  19. beforeAll(async () => {
  20. page = await program.reLaunch(PAGE_PATH)
  21. await page.waitFor(500);
  22. })
  23. it('touch-event-list-preventdefault', async () => {
  24. let x = 25
  25. let y = 350
  26. // 横向滑动事件
  27. await program.swipe({
  28. startPoint: {x: x, y: y},
  29. endPoint: {x: x+200,y: y},
  30. duration: 300
  31. })
  32. // 竖向滑动事件
  33. await program.swipe({
  34. startPoint: {x: x, y: y},
  35. endPoint: {x: x, y: 100},
  36. duration: 300
  37. })
  38. await page.waitFor(500);
  39. const scrollTop = await page.data('scrollTop')
  40. console.log("scrollTop:", scrollTop.value)
  41. expect(scrollTop.value).toBeGreaterThan(0)
  42. })
  43. })