@@ -306,14 +306,18 @@ describe('taExecCommand', function(){
306
306
} ) ;
307
307
308
308
describe ( 'handles lists correctly' , function ( ) {
309
- var taSelectionMock , $document , contents ;
309
+ var taSelectionMock , $document , contents , insertedHtml ;
310
310
beforeEach ( function ( ) {
311
+ insertedHtml = '' ;
311
312
taSelectionMock = {
312
313
element : undefined ,
313
314
getSelectionElement : function ( ) { return this . element ; } ,
314
315
getOnlySelectedElements : function ( ) { return this . element . childNodes ; } ,
315
316
setSelectionToElementStart : function ( ) { return ; } ,
316
- setSelectionToElementEnd : function ( ) { return ; }
317
+ setSelectionToElementEnd : function ( ) { return ; } ,
318
+ setSelectionAfterElement : function ( ) { return ; } ,
319
+ setSelectionBeforeElement : function ( ) { return ; } ,
320
+ insertHtml : function ( html ) { insertedHtml = html ; }
317
321
} ;
318
322
319
323
module ( function ( $provide ) {
@@ -335,6 +339,51 @@ describe('taExecCommand', function(){
335
339
$document [ 0 ] . execCommand = _temp ;
336
340
} ) ) ;
337
341
} ) ;
342
+ describe ( 'nothing selected' , function ( ) {
343
+ beforeEach ( inject ( function ( taSelection ) {
344
+ element = angular . element ( '<div><p></p></div>' ) ;
345
+ taSelection . element = element . children ( ) [ 0 ] ;
346
+ } ) ) ;
347
+ it ( 'to ol' , inject ( function ( taSelection , taExecCommand ) {
348
+ taExecCommand ( ) ( 'insertorderedlist' , false , null ) ;
349
+ expect ( element . html ( ) ) . toBe ( '<ol><li></li></ol>' ) ;
350
+ } ) ) ;
351
+
352
+ it ( 'to ul' , inject ( function ( taSelection , taExecCommand ) {
353
+ taExecCommand ( ) ( 'insertunorderedlist' , false , null ) ;
354
+ expect ( element . html ( ) ) . toBe ( '<ul><li></li></ul>' ) ;
355
+ } ) ) ;
356
+ } ) ;
357
+ describe ( 'br on line selected' , function ( ) {
358
+ beforeEach ( inject ( function ( taSelection ) {
359
+ element = angular . element ( '<div><p><br></p></div>' ) ;
360
+ taSelection . element = element . children ( ) [ 0 ] ;
361
+ } ) ) ;
362
+ it ( 'to ol' , inject ( function ( taSelection , taExecCommand ) {
363
+ taExecCommand ( ) ( 'insertorderedlist' , false , null ) ;
364
+ expect ( element . html ( ) ) . toBe ( '<ol><li><br></li></ol>' ) ;
365
+ } ) ) ;
366
+
367
+ it ( 'to ul' , inject ( function ( taSelection , taExecCommand ) {
368
+ taExecCommand ( ) ( 'insertunorderedlist' , false , null ) ;
369
+ expect ( element . html ( ) ) . toBe ( '<ul><li><br></li></ul>' ) ;
370
+ } ) ) ;
371
+ } ) ;
372
+ describe ( 'empty ta-bind' , function ( ) {
373
+ beforeEach ( inject ( function ( taSelection ) {
374
+ element = angular . element ( '<div class="ta-bind"></div>' ) ;
375
+ taSelection . element = element [ 0 ] ;
376
+ } ) ) ;
377
+ it ( 'to ol' , inject ( function ( taSelection , taExecCommand ) {
378
+ taExecCommand ( ) ( 'insertorderedlist' , false , null ) ;
379
+ expect ( insertedHtml ) . toBe ( '<ol></ol>' ) ;
380
+ } ) ) ;
381
+
382
+ it ( 'to ul' , inject ( function ( taSelection , taExecCommand ) {
383
+ taExecCommand ( ) ( 'insertunorderedlist' , false , null ) ;
384
+ expect ( insertedHtml ) . toBe ( '<ul></ul>' ) ;
385
+ } ) ) ;
386
+ } ) ;
338
387
describe ( 'single element selected' , function ( ) {
339
388
beforeEach ( inject ( function ( taSelection ) {
340
389
element = angular . element ( '<div><p>To the List!</p></div>' ) ;
0 commit comments