Skip to content

Commit 5a35b5b

Browse files
committed
reformats test a bit
1 parent 58a4671 commit 5a35b5b

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

test/test.js

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
import {subscribe} from '../dist/index.esm.js'
22

3+
const tableHtml = `
4+
<table>
5+
<thead><tr><th>name</th><th>origin</th></tr></thead>
6+
<tbody>
7+
<tr><td>hubot</td><td>github</td></tr>
8+
<tr><td>bender</td><td>futurama</td></tr>
9+
</tbody>
10+
</table>
11+
`
12+
13+
const tableMarkdown = 'name | origin\n-- | --\nhubot | github\nbender | futurama'
14+
315
describe('paste-markdown', function () {
416
describe('installed on textarea', function () {
517
let subscription
@@ -43,18 +55,10 @@ describe('paste-markdown', function () {
4355

4456
it('turns html tables into markdown', function () {
4557
const data = {
46-
'text/html': `
47-
<table>
48-
<thead><tr><th>name</th><th>origin</th></tr></thead>
49-
<tbody>
50-
<tr><td>hubot</td><td>github</td></tr>
51-
<tr><td>bender</td><td>futurama</td></tr>
52-
</tbody>
53-
</table>
54-
`
58+
'text/html': tableHtml
5559
}
5660
paste(textarea, data)
57-
assert.include(textarea.value, 'name | origin\n-- | --\nhubot | github\nbender | futurama')
61+
assert.include(textarea.value, tableMarkdown)
5862
})
5963

6064
it("doesn't execute JavaScript", async function () {
@@ -76,13 +80,7 @@ describe('paste-markdown', function () {
7680
const data = {
7781
'text/html': `
7882
<p>Here is a cool table</p>
79-
<table>
80-
<thead><tr><th>name</th><th>origin</th></tr></thead>
81-
<tbody>
82-
<tr><td>hubot</td><td>github</td></tr>
83-
<tr><td>bender</td><td>futurama</td></tr>
84-
</tbody>
85-
</table>
83+
${tableHtml}
8684
<p>Very cool</p>
8785
`
8886
}
@@ -91,7 +89,7 @@ describe('paste-markdown', function () {
9189
assert.equal(
9290
textarea.value.trim(),
9391
// eslint-disable-next-line github/unescaped-html-literal
94-
'<p>Here is a cool table</p>\n \n\nname | origin\n-- | --\nhubot | github\nbender | futurama\n\n\n <p>Very cool</p>'
92+
`<p>Here is a cool table</p>\n \n \n\n${tableMarkdown}\n\n\n\n <p>Very cool</p>`
9593
)
9694
})
9795

@@ -111,7 +109,7 @@ describe('paste-markdown', function () {
111109

112110
// Synthetic paste events don't manipulate the DOM. A empty textarea
113111
// means that the event handler didn't fire and normal paste happened.
114-
assert.equal(textarea.value, '')
112+
assertUnformattedPaste(textarea)
115113
})
116114

117115
it('accepts x-gfm', function () {
@@ -214,21 +212,18 @@ describe('paste-markdown', function () {
214212
assert.equal(textarea.value, markdownSentence)
215213
})
216214

217-
it('when dispatch keydown event (Ctrl+Shift+v) to skip formatting', function () {
215+
it('skip markdown formatting with (Ctrl+Shift+v)', function () {
218216
const data = {
219-
'text/html': `
220-
<table data-paste-markdown-skip>
221-
<thead><tr><th>name</th><th>origin</th></tr></thead>
222-
<tbody>
223-
<tr><td>hubot</td><td>github</td></tr>
224-
<tr><td>bender</td><td>futurama</td></tr>
225-
</tbody>
226-
</table>
227-
`
217+
'text/html': tableHtml
228218
}
219+
229220
dispatchSkipFormattingKeyEvent(textarea)
230221
paste(textarea, data)
231222
assertUnformattedPaste(textarea)
223+
224+
textarea.value = ''
225+
paste(textarea, data)
226+
assert.include(textarea.value, tableMarkdown)
232227
})
233228
})
234229
})

0 commit comments

Comments
 (0)