@@ -501,6 +501,7 @@ describe('TextComposer', () => {
501
501
selection : { start : 5 , end : 5 } ,
502
502
} ) ;
503
503
expect ( textComposer . text ) . toBe ( 'Hello beautiful world' ) ;
504
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 15 , end : 15 } ) ;
504
505
} ) ;
505
506
506
507
it ( 'should insert text at the end if no selection provided' , async ( ) => {
@@ -509,6 +510,7 @@ describe('TextComposer', () => {
509
510
} = setup ( { composition : message } ) ;
510
511
await textComposer . insertText ( { text : '!' } ) ;
511
512
expect ( textComposer . text ) . toBe ( 'Hello world!' ) ;
513
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 12 , end : 12 } ) ;
512
514
} ) ;
513
515
514
516
it ( 'should respect maxLengthOnEdit' , async ( ) => {
@@ -525,6 +527,7 @@ describe('TextComposer', () => {
525
527
} ) ;
526
528
await textComposer . insertText ( { text : ' beautiful world' } ) ;
527
529
expect ( textComposer . text ) . toBe ( 'Hello be' ) ;
530
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 8 , end : 8 } ) ;
528
531
} ) ;
529
532
530
533
it ( 'should handle empty text insertion' , async ( ) => {
@@ -533,6 +536,7 @@ describe('TextComposer', () => {
533
536
} = setup ( { composition : message } ) ;
534
537
await textComposer . insertText ( { text : '' , selection : { start : 5 , end : 5 } } ) ;
535
538
expect ( textComposer . text ) . toBe ( 'Hello world' ) ;
539
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 5 , end : 5 } ) ;
536
540
} ) ;
537
541
538
542
it ( 'should handle insertion at the start of text' , async ( ) => {
@@ -541,6 +545,7 @@ describe('TextComposer', () => {
541
545
} = setup ( { composition : message } ) ;
542
546
await textComposer . insertText ( { text : 'Hi ' , selection : { start : 0 , end : 0 } } ) ;
543
547
expect ( textComposer . text ) . toBe ( 'Hi Hello world' ) ;
548
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 3 , end : 3 } ) ;
544
549
} ) ;
545
550
546
551
it ( 'should handle insertion at end of text' , async ( ) => {
@@ -549,6 +554,7 @@ describe('TextComposer', () => {
549
554
} = setup ( { composition : message } ) ;
550
555
await textComposer . insertText ( { text : '!' , selection : { start : 11 , end : 11 } } ) ;
551
556
expect ( textComposer . text ) . toBe ( 'Hello world!' ) ;
557
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 12 , end : 12 } ) ;
552
558
} ) ;
553
559
554
560
it ( 'should handle insertion with multi-character selection' , async ( ) => {
@@ -557,6 +563,7 @@ describe('TextComposer', () => {
557
563
} = setup ( { composition : message } ) ;
558
564
await textComposer . insertText ( { text : 'Hi' , selection : { start : 0 , end : 5 } } ) ;
559
565
expect ( textComposer . text ) . toBe ( 'Hi world' ) ;
566
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 2 , end : 2 } ) ;
560
567
} ) ;
561
568
562
569
it ( 'should handle insertion with multi-character selection and maxLengthOnEdit restricting the size' , async ( ) => {
@@ -577,6 +584,7 @@ describe('TextComposer', () => {
577
584
selection : { start : 7 , end : 9 } ,
578
585
} ) ;
579
586
expect ( textComposer . text ) . toBe ( 'Hello wHi ' ) ;
587
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 10 , end : 10 } ) ;
580
588
} ) ;
581
589
582
590
it ( 'should not insert text if disabled' , async ( ) => {
@@ -588,6 +596,7 @@ describe('TextComposer', () => {
588
596
selection : { start : 5 , end : 5 } ,
589
597
} ) ;
590
598
expect ( textComposer . text ) . toBe ( message . text ) ;
599
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 11 , end : 11 } ) ;
591
600
} ) ;
592
601
593
602
it ( 'should reflect pasting of command trigger with partial command name' , async ( ) => {
@@ -597,6 +606,7 @@ describe('TextComposer', () => {
597
606
await textComposer . insertText ( { text : '/giph' , selection : { start : 0 , end : 11 } } ) ;
598
607
expect ( textComposer . text ) . toBe ( '/giph' ) ;
599
608
expect ( textComposer . suggestions ) . toBeDefined ( ) ;
609
+ expect ( textComposer . selection ) . toStrictEqual ( { start : 5 , end : 5 } ) ;
600
610
} ) ;
601
611
} ) ;
602
612
0 commit comments