Brak opisu

arrow.test.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @jest-environment puppeteer
  3. * @flow
  4. */
  5. import { scroll, screenshot } from '../utils/puppeteer.js';
  6. it('shuld center the arrow', async () => {
  7. const page = await browser.newPage();
  8. await page.goto(`${TEST_URL}/modifiers/arrow/main.html`);
  9. await scroll(page, '.scroll3', 300);
  10. await scroll(page, '.scroll2', 200);
  11. await scroll(page, '.scroll1', 200);
  12. expect(await screenshot(page)).toMatchImageSnapshot();
  13. });
  14. it('should keep arrow within popper edges', async () => {
  15. const page = await browser.newPage();
  16. await page.goto(`${TEST_URL}/modifiers/arrow/main.html`);
  17. await scroll(page, '.scroll2', 400);
  18. await scroll(page, '.scroll3', 200);
  19. await scroll(page, '.scroll1', 450);
  20. expect(await screenshot(page)).toMatchImageSnapshot();
  21. });
  22. it('tether should activate at correct time', async () => {
  23. const page = await browser.newPage();
  24. await page.goto(`${TEST_URL}/modifiers/arrow/main.html`);
  25. await scroll(page, '.scroll2', 400);
  26. await scroll(page, '.scroll3', 200);
  27. await scroll(page, '.scroll1', 490);
  28. expect(await screenshot(page)).toMatchImageSnapshot();
  29. });
  30. it('should hide arrow if it is at the edge (min)', async () => {
  31. const page = await browser.newPage();
  32. await page.goto(`${TEST_URL}/modifiers/arrow/hide.html`);
  33. await scroll(page, '.scroll', 390);
  34. expect(await screenshot(page)).toMatchImageSnapshot();
  35. });
  36. it('should hide arrow if it is at the edge (max)', async () => {
  37. const page = await browser.newPage();
  38. await page.setViewport({ width: 800, height: 400 });
  39. await page.goto(`${TEST_URL}/modifiers/arrow/hide.html`);
  40. expect(await screenshot(page)).toMatchImageSnapshot();
  41. });