Skip to content

Commit 08ede8f

Browse files
committed
Add tests for list hotkeys
1 parent 6213bb2 commit 08ede8f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

test/test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ describe('markdown-toolbar-element', function () {
3434
textarea.dispatchEvent(event)
3535
}
3636

37-
function pressHotkey(hotkey) {
37+
function pressHotkey(hotkey, explicitShiftKey = false) {
3838
const textarea = document.querySelector('textarea')
3939
const osx = navigator.userAgent.indexOf('Macintosh') !== -1
4040
const event = document.createEvent('Event')
4141
event.initEvent('keydown', true, true)
4242
event.metaKey = osx
4343
event.ctrlKey = !osx
44-
event.shiftKey = hotkey === hotkey.toUpperCase()
44+
event.shiftKey = (hotkey === hotkey.toUpperCase() && hotkey !== hotkey.toLowerCase()) || explicitShiftKey
4545

4646
// emulate existing osx browser bug
4747
// https://bugs.webkit.org/show_bug.cgi?id=174782
@@ -556,6 +556,22 @@ describe('markdown-toolbar-element', function () {
556556
assert.equal('One\n\n|- Two\n- Three|\n', visualValue())
557557
})
558558

559+
it('turns multiple lines into unordered list via hotkey, requiring shift', function () {
560+
setVisualValue('One\n|Two\nThree|\n')
561+
pressHotkey('8', false)
562+
assert.equal('One\n|Two\nThree|\n', visualValue())
563+
pressHotkey('8', true)
564+
assert.equal('One\n\n|- Two\n- Three|\n', visualValue())
565+
})
566+
567+
it('turns multiple lines into ordered list via hotkey, requiring shift', function () {
568+
setVisualValue('One\n|Two\nThree|\n')
569+
pressHotkey('9', false)
570+
assert.equal('One\n|Two\nThree|\n', visualValue())
571+
pressHotkey('9', true)
572+
assert.equal('One\n\n|1. Two\n2. Three|\n', visualValue())
573+
})
574+
559575
it('prefixes newlines when a list is created on the last line', function () {
560576
setVisualValue("Here's a list:|One|")
561577
clickToolbar('md-unordered-list')

0 commit comments

Comments
 (0)