@@ -41,7 +41,12 @@ describe('markdown-toolbar-element', function () {
41
41
event . initEvent ( 'keydown' , true , true )
42
42
event . metaKey = osx
43
43
event . ctrlKey = ! osx
44
- event . key = hotkey
44
+ event . shiftKey = hotkey === hotkey . toUpperCase ( )
45
+
46
+ // emulate existing osx browser bug
47
+ // https://bugs.webkit.org/show_bug.cgi?id=174782
48
+ event . key = osx ? hotkey . toLowerCase ( ) : hotkey
49
+
45
50
textarea . dispatchEvent ( event )
46
51
}
47
52
@@ -193,6 +198,22 @@ describe('markdown-toolbar-element', function () {
193
198
} )
194
199
} )
195
200
201
+ describe ( 'hotkey case-sensitivity' , function ( ) {
202
+ it ( 'does not bold selected text when using the uppercased hotkey' , function ( ) {
203
+ focus ( )
204
+ setVisualValue ( 'The |quick| brown fox jumps over the lazy dog' )
205
+ pressHotkey ( 'B' ) // capital `B` instead of lowercase `b`
206
+ assert . equal ( 'The |quick| brown fox jumps over the lazy dog' , visualValue ( ) )
207
+ } )
208
+
209
+ it ( 'does not codeblock selected text when using the lowercased hotkey' , function ( ) {
210
+ focus ( )
211
+ setVisualValue ( 'The |quick| brown fox jumps over the lazy dog' )
212
+ pressHotkey ( 'e' ) // lowercase `e` instead of uppercase `E`
213
+ assert . equal ( 'The |quick| brown fox jumps over the lazy dog' , visualValue ( ) )
214
+ } )
215
+ } )
216
+
196
217
describe ( 'bold' , function ( ) {
197
218
it ( 'bold selected text when you click the bold icon' , function ( ) {
198
219
setVisualValue ( 'The |quick| brown fox jumps over the lazy dog' )
@@ -605,6 +626,13 @@ describe('markdown-toolbar-element', function () {
605
626
assert . equal ( "`|puts 'Hello, world!'|`" , visualValue ( ) )
606
627
} )
607
628
629
+ it ( 'surrounds a line with backticks via hotkey' , function ( ) {
630
+ focus ( )
631
+ setVisualValue ( "|puts 'Hello, world!'|" )
632
+ pressHotkey ( 'E' )
633
+ assert . equal ( "`|puts 'Hello, world!'|`" , visualValue ( ) )
634
+ } )
635
+
608
636
it ( 'surrounds multiple lines with triple backticks if you click the code icon' , function ( ) {
609
637
setVisualValue ( '|class Greeter\n def hello_world\n "Hello World!"\n end\nend|' )
610
638
clickToolbar ( 'md-code' )
0 commit comments