Skip to content

Commit fea55a6

Browse files
wrong deletion
1 parent f5a1678 commit fea55a6

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/test.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ describe('paste-markdown', function () {
128128
assert.include(textarea.value, '# hello')
129129
})
130130

131+
it('turns one html link into a markdown link', function () {
132+
// eslint-disable-next-line github/unescaped-html-literal
133+
const link = `<meta charset='utf-8'><meta charset="utf-8">
134+
<b><a href="https://github.com/" style="text-decoration:none;"><span>link</span></a></b>`
135+
const plaintextLink = 'link'
136+
const markdownLink = '[link](https://github.com/)'
137+
138+
paste(textarea, {'text/html': link, 'text/plain': plaintextLink})
139+
assert.equal(textarea.value, markdownLink)
140+
})
141+
131142
it('turns mixed html content containing several links into appropriate markdown', function () {
132143
// eslint-disable-next-line github/unescaped-html-literal
133144
const sentence = `<meta charset='utf-8'>
@@ -214,17 +225,6 @@ describe('paste-markdown', function () {
214225
})
215226
})
216227

217-
function paste(textarea, data) {
218-
const dataTransfer = new DataTransfer()
219-
for (const key in data) {
220-
dataTransfer.setData(key, data[key])
221-
}
222-
const event = new ClipboardEvent('paste', {
223-
clipboardData: dataTransfer
224-
})
225-
textarea.dispatchEvent(event)
226-
}
227-
228228
function skipFormatting(textarea) {
229229
textarea.dispatchEvent(
230230
new KeyboardEvent('keydown', {
@@ -237,6 +237,17 @@ function skipFormatting(textarea) {
237237
)
238238
}
239239

240+
function paste(textarea, data) {
241+
const dataTransfer = new DataTransfer()
242+
for (const key in data) {
243+
dataTransfer.setData(key, data[key])
244+
}
245+
const event = new ClipboardEvent('paste', {
246+
clipboardData: dataTransfer
247+
})
248+
textarea.dispatchEvent(event)
249+
}
250+
240251
function wait(ms) {
241252
return new Promise(resolve => setTimeout(resolve, ms))
242253
}

0 commit comments

Comments
 (0)