markdown.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import path from 'path'
  2. import { setupPuppeteer } 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(16)
  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('classic', async () => {
  25. await testMarkdown('classic')
  26. })
  27. test('composition', async () => {
  28. await testMarkdown('composition')
  29. })
  30. })