2
0

markdown.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import path from 'path'
  2. import {
  3. setupPuppeteer,
  4. expectByPolling,
  5. E2E_TIMEOUT
  6. } from '../../__tests__/e2eUtils'
  7. describe('e2e: markdown', () => {
  8. const { page, isVisible, value, html } = setupPuppeteer()
  9. async function testMarkdown(apiType: 'classic' | 'composition') {
  10. const baseUrl = `file://${path.resolve(
  11. __dirname,
  12. `../${apiType}/markdown.html#test`
  13. )}`
  14. await page().goto(baseUrl)
  15. expect(await isVisible('#editor')).toBe(true)
  16. expect(await value('textarea')).toBe('# hello')
  17. expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
  18. await page().type('textarea', '\n## foo\n\n- bar\n- baz')
  19. // assert the output is not updated yet because of debounce
  20. expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
  21. await expectByPolling(
  22. () => html('#editor div'),
  23. '<h1 id="hello">hello</h1>\n' +
  24. '<h2 id="foo">foo</h2>\n' +
  25. '<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'
  26. )
  27. }
  28. test(
  29. 'classic',
  30. async () => {
  31. await testMarkdown('classic')
  32. },
  33. E2E_TIMEOUT
  34. )
  35. test(
  36. 'composition',
  37. async () => {
  38. await testMarkdown('composition')
  39. },
  40. E2E_TIMEOUT
  41. )
  42. })