markdown.spec.ts 1.2 KB

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