@@ -41,7 +41,12 @@ describe('markdown-toolbar-element', function () {
4141 event . initEvent ( 'keydown' , true , true )
4242 event . metaKey = osx
4343 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+
4550 textarea . dispatchEvent ( event )
4651 }
4752
@@ -193,6 +198,22 @@ describe('markdown-toolbar-element', function () {
193198 } )
194199 } )
195200
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+
196217 describe ( 'bold' , function ( ) {
197218 it ( 'bold selected text when you click the bold icon' , function ( ) {
198219 setVisualValue ( 'The |quick| brown fox jumps over the lazy dog' )
@@ -605,6 +626,13 @@ describe('markdown-toolbar-element', function () {
605626 assert . equal ( "`|puts 'Hello, world!'|`" , visualValue ( ) )
606627 } )
607628
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+
608636 it ( 'surrounds multiple lines with triple backticks if you click the code icon' , function ( ) {
609637 setVisualValue ( '|class Greeter\n def hello_world\n "Hello World!"\n end\nend|' )
610638 clickToolbar ( 'md-code' )
0 commit comments