sticky-section.test.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isMP = platformInfo.startsWith('mp')
  3. const isHarmony = platformInfo.startsWith('harmony')
  4. const isWeb = platformInfo.startsWith('web')
  5. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  6. describe('component-native-sticky-section', () => {
  7. if (isMP) {
  8. it('not support', () => {
  9. expect(1).toBe(1)
  10. })
  11. return
  12. }
  13. let page
  14. beforeAll(async () => {
  15. page = await program.reLaunch('/pages/component/sticky-section/sticky-section')
  16. // harmony querySelector('sticky-section') 取不到
  17. await page.waitFor('sticky-section')
  18. })
  19. it('check_delete_and_refresher', async () => {
  20. await page.callMethod('deleteSection')
  21. await page.waitFor(400)
  22. await page.setData({
  23. refresherTriggered: true
  24. })
  25. await page.waitFor(500)
  26. await page.setData({
  27. refresherTriggered: false
  28. })
  29. await page.waitFor(2000)
  30. const image = await program.screenshot({fullPage: true});
  31. expect(image).toSaveImageSnapshot();
  32. })
  33. //检测吸顶上推效果
  34. it('check_sticky_section', async () => {
  35. await page.waitFor(async () => {
  36. return await page.data('isReady') === true;
  37. });
  38. page.waitFor(600)
  39. await page.callMethod('listViewScrollByY', 1000)
  40. const image = await program.screenshot({fullPage: true});
  41. expect(image).toSaveImageSnapshot();
  42. })
  43. if (isWeb || isAppWebView) {
  44. return
  45. }
  46. it('check_goto_sticky_header', async () => {
  47. //滚动回顶部
  48. await page.callMethod('toTop')
  49. page.waitFor(100)
  50. await page.setData({
  51. scrolling: true
  52. })
  53. if (!isAppWebView) {
  54. //跳转到id为C的StickyHeader位置
  55. await page.callMethod('gotoStickyHeader', 'C')
  56. }
  57. await page.waitFor(async () => {
  58. return await page.data('scrolling') === false;
  59. });
  60. const image = await program.screenshot({fullPage: true});
  61. expect(image).toSaveImageSnapshot();
  62. })
  63. })