@@ -92,6 +92,7 @@ describe('markdown-toolbar-element', function () {
92
92
<md-header level="10">h1</md-header>
93
93
<div data-md-button>Other button</div>
94
94
<md-italic>italic</md-italic>
95
+ <md-strikethrough>strikethrough</md-strikethrough>
95
96
<md-quote>quote</md-quote>
96
97
<md-code>code</md-code>
97
98
<md-link>link</md-link>
@@ -135,47 +136,47 @@ describe('markdown-toolbar-element', function () {
135
136
it ( 'moves focus to next button when ArrowRight is pressed' , function ( ) {
136
137
focusFirstButton ( )
137
138
pushKeyOnFocussedButton ( 'ArrowRight' )
138
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
139
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
139
140
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header' ) ] )
140
141
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
141
142
pushKeyOnFocussedButton ( 'ArrowRight' )
142
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
143
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
143
144
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header[level="1"]' ) ] )
144
145
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
145
146
pushKeyOnFocussedButton ( 'ArrowRight' )
146
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
147
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
147
148
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-header[level="10"]' ) ] )
148
149
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
149
150
} )
150
151
151
152
it ( 'cycles focus round to last element from first when ArrowLeft is pressed' , function ( ) {
152
153
focusFirstButton ( )
153
154
pushKeyOnFocussedButton ( 'ArrowLeft' )
154
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
155
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
155
156
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
156
157
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
157
158
pushKeyOnFocussedButton ( 'ArrowLeft' )
158
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
159
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
159
160
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-mention' ) ] )
160
161
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
161
162
} )
162
163
163
164
it ( 'focussed first/last button when Home/End key is pressed' , function ( ) {
164
165
focusFirstButton ( )
165
166
pushKeyOnFocussedButton ( 'End' )
166
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
167
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
167
168
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
168
169
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
169
170
pushKeyOnFocussedButton ( 'End' )
170
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
171
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
171
172
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-ref' ) ] )
172
173
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
173
174
pushKeyOnFocussedButton ( 'Home' )
174
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
175
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
175
176
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-bold' ) ] )
176
177
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
177
178
pushKeyOnFocussedButton ( 'Home' )
178
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
179
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
179
180
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'md-bold' ) ] )
180
181
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
181
182
} )
@@ -186,7 +187,7 @@ describe('markdown-toolbar-element', function () {
186
187
pushKeyOnFocussedButton ( 'ArrowRight' )
187
188
pushKeyOnFocussedButton ( 'ArrowRight' )
188
189
pushKeyOnFocussedButton ( 'ArrowRight' )
189
- assert . equal ( getElementsWithTabindex ( - 1 ) . length , 14 )
190
+ assert . equal ( getElementsWithTabindex ( - 1 ) . length , 15 )
190
191
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . querySelector ( 'div[data-md-button]' ) ] )
191
192
assert . deepEqual ( getElementsWithTabindex ( 0 ) , [ document . activeElement ] )
192
193
} )
@@ -390,6 +391,62 @@ describe('markdown-toolbar-element', function () {
390
391
} )
391
392
} )
392
393
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
+
393
450
describe ( 'quote level' , function ( ) {
394
451
it ( 'inserts selected quoted sample if you click the quote icon' , function ( ) {
395
452
setVisualValue ( '' )
0 commit comments