reformats test a bit
This commit is contained in:
Родитель
58a4671628
Коммит
5a35b5b858
53
test/test.js
53
test/test.js
|
@ -1,5 +1,17 @@
|
|||
import {subscribe} from '../dist/index.esm.js'
|
||||
|
||||
const tableHtml = `
|
||||
<table>
|
||||
<thead><tr><th>name</th><th>origin</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>hubot</td><td>github</td></tr>
|
||||
<tr><td>bender</td><td>futurama</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
`
|
||||
|
||||
const tableMarkdown = 'name | origin\n-- | --\nhubot | github\nbender | futurama'
|
||||
|
||||
describe('paste-markdown', function () {
|
||||
describe('installed on textarea', function () {
|
||||
let subscription
|
||||
|
@ -43,18 +55,10 @@ describe('paste-markdown', function () {
|
|||
|
||||
it('turns html tables into markdown', function () {
|
||||
const data = {
|
||||
'text/html': `
|
||||
<table>
|
||||
<thead><tr><th>name</th><th>origin</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>hubot</td><td>github</td></tr>
|
||||
<tr><td>bender</td><td>futurama</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
`
|
||||
'text/html': tableHtml
|
||||
}
|
||||
paste(textarea, data)
|
||||
assert.include(textarea.value, 'name | origin\n-- | --\nhubot | github\nbender | futurama')
|
||||
assert.include(textarea.value, tableMarkdown)
|
||||
})
|
||||
|
||||
it("doesn't execute JavaScript", async function () {
|
||||
|
@ -76,13 +80,7 @@ describe('paste-markdown', function () {
|
|||
const data = {
|
||||
'text/html': `
|
||||
<p>Here is a cool table</p>
|
||||
<table>
|
||||
<thead><tr><th>name</th><th>origin</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>hubot</td><td>github</td></tr>
|
||||
<tr><td>bender</td><td>futurama</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
${tableHtml}
|
||||
<p>Very cool</p>
|
||||
`
|
||||
}
|
||||
|
@ -91,7 +89,7 @@ describe('paste-markdown', function () {
|
|||
assert.equal(
|
||||
textarea.value.trim(),
|
||||
// eslint-disable-next-line github/unescaped-html-literal
|
||||
'<p>Here is a cool table</p>\n \n\nname | origin\n-- | --\nhubot | github\nbender | futurama\n\n\n <p>Very cool</p>'
|
||||
`<p>Here is a cool table</p>\n \n \n\n${tableMarkdown}\n\n\n\n <p>Very cool</p>`
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -111,7 +109,7 @@ describe('paste-markdown', function () {
|
|||
|
||||
// Synthetic paste events don't manipulate the DOM. A empty textarea
|
||||
// means that the event handler didn't fire and normal paste happened.
|
||||
assert.equal(textarea.value, '')
|
||||
assertUnformattedPaste(textarea)
|
||||
})
|
||||
|
||||
it('accepts x-gfm', function () {
|
||||
|
@ -214,21 +212,18 @@ describe('paste-markdown', function () {
|
|||
assert.equal(textarea.value, markdownSentence)
|
||||
})
|
||||
|
||||
it('when dispatch keydown event (Ctrl+Shift+v) to skip formatting', function () {
|
||||
it('skip markdown formatting with (Ctrl+Shift+v)', function () {
|
||||
const data = {
|
||||
'text/html': `
|
||||
<table data-paste-markdown-skip>
|
||||
<thead><tr><th>name</th><th>origin</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>hubot</td><td>github</td></tr>
|
||||
<tr><td>bender</td><td>futurama</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
`
|
||||
'text/html': tableHtml
|
||||
}
|
||||
|
||||
dispatchSkipFormattingKeyEvent(textarea)
|
||||
paste(textarea, data)
|
||||
assertUnformattedPaste(textarea)
|
||||
|
||||
textarea.value = ''
|
||||
paste(textarea, data)
|
||||
assert.include(textarea.value, tableMarkdown)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче