@@ -92,6 +92,7 @@ describe('markdown-toolbar-element', function () {
9292 <md-header level="10">h1</md-header>
9393 <div data-md-button>Other button</div>
9494 <md-italic>italic</md-italic>
95+ <md-strikethrough>strikethrough</md-strikethrough>
9596 <md-quote>quote</md-quote>
9697 <md-code>code</md-code>
9798 <md-link>link</md-link>
@@ -135,47 +136,47 @@ describe('markdown-toolbar-element', function () {
135136 it ( 'moves focus to next button when ArrowRight is pressed' , function ( ) {
136137 focusFirstButton ( )
137138 pushKeyOnFocussedButton ( 'ArrowRight' )
138- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
139+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
139140 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header' ) ] )
140141 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
141142 pushKeyOnFocussedButton ( 'ArrowRight' )
142- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
143+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
143144 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header[level="1"]' ) ] )
144145 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
145146 pushKeyOnFocussedButton ( 'ArrowRight' )
146- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
147+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
147148 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header[level="10"]' ) ] )
148149 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
149150 } )
150151
151152 it ( 'cycles focus round to last element from first when ArrowLeft is pressed' , function ( ) {
152153 focusFirstButton ( )
153154 pushKeyOnFocussedButton ( 'ArrowLeft' )
154- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
155+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
155156 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
156157 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
157158 pushKeyOnFocussedButton ( 'ArrowLeft' )
158- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
159+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
159160 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-mention' ) ] )
160161 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
161162 } )
162163
163164 it ( 'focussed first/last button when Home/End key is pressed' , function ( ) {
164165 focusFirstButton ( )
165166 pushKeyOnFocussedButton ( 'End' )
166- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
167+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
167168 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
168169 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
169170 pushKeyOnFocussedButton ( 'End' )
170- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
171+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
171172 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
172173 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
173174 pushKeyOnFocussedButton ( 'Home' )
174- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
175+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
175176 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-bold' ) ] )
176177 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
177178 pushKeyOnFocussedButton ( 'Home' )
178- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
179+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
179180 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-bold' ) ] )
180181 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
181182 } )
@@ -186,7 +187,7 @@ describe('markdown-toolbar-element', function () {
186187 pushKeyOnFocussedButton ( 'ArrowRight' )
187188 pushKeyOnFocussedButton ( 'ArrowRight' )
188189 pushKeyOnFocussedButton ( 'ArrowRight' )
189- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
190+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
190191 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'div[data-md-button]' ) ] )
191192 assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
192193 } )
@@ -390,6 +391,62 @@ describe('markdown-toolbar-element', function () {
390391 } )
391392 } )
392393
394+ describe ( 'strikethrough' , function ( ) {
395+ it ( 'strikes through selected text when you click the strikethrough icon' , function ( ) {
396+ setVisualValue ( 'The |quick| brown fox jumps over the lazy dog' )
397+ clickToolbar ( 'md-strikethrough' )
398+ assert . equal ( 'The ~~|quick|~~ brown fox jumps over the lazy dog' , visualValue ( ) )
399+ } )
400+
401+ it ( 'strikes through when there is leading whitespace in selection' , function ( ) {
402+ setVisualValue ( '| \nHello world|' )
403+ clickToolbar ( 'md-strikethrough' )
404+ assert . equal ( ' \n~~|Hello world|~~' , visualValue ( ) )
405+ } )
406+
407+ it ( 'strikes through when there is trailing whitespace in selection' , function ( ) {
408+ setVisualValue ( '|Hello world\n \t|' )
409+ clickToolbar ( 'md-strikethrough' )
410+ assert . equal ( '~~|Hello world|~~\n \t' , visualValue ( ) )
411+ } )
412+
413+ it ( 'strikes through empty selection and textarea inserts ~~ with cursor ready to type inside' , function ( ) {
414+ setVisualValue ( '|' )
415+ clickToolbar ( 'md-strikethrough' )
416+ assert . equal ( '~~|~~' , visualValue ( ) )
417+ } )
418+
419+ it ( 'strikes through empty selection with previous text inserts ~~ with cursor ready to type inside' , function ( ) {
420+ setVisualValue ( 'The |' )
421+ clickToolbar ( 'md-strikethrough' )
422+ assert . equal ( 'The ~~|~~' , visualValue ( ) )
423+ } )
424+
425+ it ( 'strikes through selected word when cursor is at the start of the word' , function ( ) {
426+ setVisualValue ( 'The |quick brown fox jumps over the lazy dog' )
427+ clickToolbar ( 'md-strikethrough' )
428+ assert . equal ( 'The ~~|quick~~ brown fox jumps over the lazy dog' , visualValue ( ) )
429+ } )
430+
431+ it ( 'strikes through selected word when cursor is in the middle of the word' , function ( ) {
432+ setVisualValue ( 'The qui|ck brown fox jumps over the lazy dog' )
433+ clickToolbar ( 'md-strikethrough' )
434+ assert . equal ( 'The ~~qui|ck~~ brown fox jumps over the lazy dog' , visualValue ( ) )
435+ } )
436+
437+ it ( 'strikes through selected word when cursor is at the end of the word' , function ( ) {
438+ setVisualValue ( 'The quick| brown fox jumps over the lazy dog' )
439+ clickToolbar ( 'md-strikethrough' )
440+ assert . equal ( 'The ~~quick|~~ brown fox jumps over the lazy dog' , visualValue ( ) )
441+ } )
442+
443+ it ( 'un-strikes through selected struck-through text when you click the strikethrough icon' , function ( ) {
444+ setVisualValue ( 'The ~~|quick|~~ brown fox jumps over the lazy dog' )
445+ clickToolbar ( 'md-strikethrough' )
446+ assert . equal ( 'The |quick| brown fox jumps over the lazy dog' , visualValue ( ) )
447+ } )
448+ } )
449+
393450 describe ( 'quote level' , function ( ) {
394451 it ( 'inserts selected quoted sample if you click the quote icon' , function ( ) {
395452 setVisualValue ( '' )
0 commit comments