nested-scroll-body.test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isMP = platformInfo.startsWith('mp')
  3. const isIOS = platformInfo.startsWith('ios')
  4. const isAndroid = platformInfo.startsWith('android')
  5. const isHarmony = platformInfo.startsWith('harmony')
  6. const isWeb = platformInfo.startsWith('web')
  7. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  8. describe('component-native-nested-scroll-body', () => {
  9. if (isMP || isWeb || isAppWebView) {
  10. it('dummyTest', () => {
  11. expect(1).toBe(1)
  12. })
  13. return
  14. }
  15. let page
  16. //检测横向scroll_into_view属性赋值
  17. it('check_scroll_into_view_left', async () => {
  18. page = await program.reLaunch('/pages/component/nested-scroll-body/nested-scroll-body')
  19. await page.waitFor('view')
  20. await page.waitFor(1000)
  21. await page.callMethod('testBodyScrollBy', 400)
  22. await page.waitFor(300)
  23. const image = await program.screenshot({fullPage: true});
  24. expect(image).toSaveImageSnapshot();
  25. })
  26. if(isIOS || isAndroid || isHarmony){
  27. it('check_scroll', async () => {
  28. await page.waitFor(300)
  29. let x = 100
  30. let y = 450
  31. await program.swipe({
  32. startPoint: {x: x, y: y},
  33. endPoint: {x: x,y: 0},
  34. duration: 300
  35. })
  36. await page.waitFor(300)
  37. y = 200
  38. await program.swipe({
  39. startPoint: {x: x, y: y},
  40. endPoint: {x: x,y: y + 100},
  41. duration: 300
  42. })
  43. await page.waitFor(300)
  44. let scrollTop = await page.data('testScrollTop')
  45. expect(scrollTop).toBeLessThan(250)
  46. })
  47. }
  48. })