2019-12-11 22:13:47 +08:00
|
|
|
import path from 'path'
|
2020-02-06 10:10:43 +08:00
|
|
|
import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
|
2019-12-11 22:13:47 +08:00
|
|
|
|
|
|
|
describe('e2e: markdown', () => {
|
|
|
|
const { page, isVisible, value, html } = setupPuppeteer()
|
|
|
|
|
|
|
|
async function testMarkdown(apiType: 'classic' | 'composition') {
|
|
|
|
const baseUrl = `file://${path.resolve(
|
|
|
|
__dirname,
|
2019-12-11 23:37:03 +08:00
|
|
|
`../${apiType}/markdown.html#test`
|
2019-12-11 22:13:47 +08:00
|
|
|
)}`
|
|
|
|
|
|
|
|
await page().goto(baseUrl)
|
|
|
|
expect(await isVisible('#editor')).toBe(true)
|
|
|
|
expect(await value('textarea')).toBe('# hello')
|
|
|
|
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
|
|
|
|
|
|
|
|
await page().type('textarea', '\n## foo\n\n- bar\n- baz')
|
|
|
|
// assert the output is not updated yet because of debounce
|
|
|
|
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
|
2020-02-14 14:36:42 +08:00
|
|
|
await page().waitFor(30)
|
2019-12-11 22:13:47 +08:00
|
|
|
expect(await html('#editor div')).toBe(
|
|
|
|
'<h1 id="hello">hello</h1>\n' +
|
|
|
|
'<h2 id="foo">foo</h2>\n' +
|
|
|
|
'<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-02-06 10:10:43 +08:00
|
|
|
test(
|
|
|
|
'classic',
|
|
|
|
async () => {
|
|
|
|
await testMarkdown('classic')
|
|
|
|
},
|
|
|
|
E2E_TIMEOUT
|
|
|
|
)
|
2019-12-11 22:13:47 +08:00
|
|
|
|
2020-02-06 10:10:43 +08:00
|
|
|
test(
|
|
|
|
'composition',
|
|
|
|
async () => {
|
|
|
|
await testMarkdown('composition')
|
|
|
|
},
|
|
|
|
E2E_TIMEOUT
|
|
|
|
)
|
2019-12-11 22:13:47 +08:00
|
|
|
})
|