Skip to content

Commit 688561f

Browse files
committed
extract test helper
1 parent a6a0739 commit 688561f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@ describe('paste-markdown', function () {
214214
assert.equal(textarea.value, markdownSentence)
215215
})
216216

217-
// Note: It's possible to construct and dispatch a synthetic paste event,
218-
// but this will not affect the document's contents in tests to assert it.
219-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
220-
// So for that reason assert result on keydown (Ctrl+Shift+v) will be empty '' here.
221217
it('when dispatch keydown event (Ctrl+Shift+v) to skip formatting', function () {
222218
const data = {
223219
'text/html': `
@@ -232,11 +228,21 @@ describe('paste-markdown', function () {
232228
}
233229
textarea.addEventListener('keydown', dispatchSkipFormattingKeyEvent(textarea))
234230
paste(textarea, data)
235-
assert.equal(textarea.value, '')
231+
assertUnformattedPaste(textarea)
236232
})
237233
})
238234
})
239235

236+
/**
237+
* Note: It's possible to construct and dispatch a synthetic paste event,
238+
* but this will not affect the document's contents in tests to assert it.
239+
* https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
240+
* So for that reason assert result on keydown (Ctrl+Shift+v) will be empty '' here.
241+
*/
242+
function assertUnformattedPaste(textarea) {
243+
return assert.equal(textarea.value, '')
244+
}
245+
240246
function dispatchSkipFormattingKeyEvent(textarea) {
241247
textarea.dispatchEvent(
242248
new KeyboardEvent('keydown', {

0 commit comments

Comments
 (0)