@@ -79,9 +79,9 @@ describe("handleInlineStyle", () => {
7979 } ,
8080 selection : new SelectionState ( {
8181 anchorKey : "item1" ,
82- anchorOffset : 14 ,
82+ anchorOffset : 16 ,
8383 focusKey : "item1" ,
84- focusOffset : 14 ,
84+ focusOffset : 16 ,
8585 isBackward : false ,
8686 hasFocus : true ,
8787 } ) ,
@@ -123,9 +123,9 @@ describe("handleInlineStyle", () => {
123123 } ,
124124 selection : new SelectionState ( {
125125 anchorKey : "item1" ,
126- anchorOffset : 14 ,
126+ anchorOffset : 16 ,
127127 focusKey : "item1" ,
128- focusOffset : 14 ,
128+ focusOffset : 16 ,
129129 isBackward : false ,
130130 hasFocus : true ,
131131 } ) ,
@@ -167,9 +167,9 @@ describe("handleInlineStyle", () => {
167167 } ,
168168 selection : new SelectionState ( {
169169 anchorKey : "item1" ,
170- anchorOffset : 14 ,
170+ anchorOffset : 16 ,
171171 focusKey : "item1" ,
172- focusOffset : 14 ,
172+ focusOffset : 16 ,
173173 isBackward : false ,
174174 hasFocus : true ,
175175 } ) ,
@@ -310,9 +310,9 @@ describe("handleInlineStyle", () => {
310310 } ,
311311 selection : new SelectionState ( {
312312 anchorKey : "item1" ,
313- anchorOffset : 14 ,
313+ anchorOffset : 16 ,
314314 focusKey : "item1" ,
315- focusOffset : 14 ,
315+ focusOffset : 16 ,
316316 isBackward : false ,
317317 hasFocus : true ,
318318 } ) ,
@@ -398,9 +398,9 @@ describe("handleInlineStyle", () => {
398398 } ,
399399 selection : new SelectionState ( {
400400 anchorKey : "item1" ,
401- anchorOffset : 14 ,
401+ anchorOffset : 16 ,
402402 focusKey : "item1" ,
403- focusOffset : 14 ,
403+ focusOffset : 16 ,
404404 isBackward : false ,
405405 hasFocus : true ,
406406 } ) ,
@@ -456,9 +456,9 @@ describe("handleInlineStyle", () => {
456456 } ,
457457 selection : new SelectionState ( {
458458 anchorKey : "item1" ,
459- anchorOffset : 14 ,
459+ anchorOffset : 16 ,
460460 focusKey : "item1" ,
461- focusOffset : 14 ,
461+ focusOffset : 16 ,
462462 isBackward : false ,
463463 hasFocus : true ,
464464 } ) ,
@@ -529,7 +529,25 @@ describe("handleInlineStyle", () => {
529529 EditorState . createWithContent ( contentState ) ,
530530 selection
531531 ) ;
532- it ( "converts block type" , ( ) => {
532+
533+ const wrongSelectionState = selection . merge ( {
534+ anchorOffset : 0 ,
535+ focusOffset : 0 ,
536+ } ) ;
537+ const sameEditorState = EditorState . forceSelection (
538+ editorState ,
539+ wrongSelectionState
540+ ) ;
541+
542+ it ( "does not convert markdown to style or block type if selection is at the wrong place" , ( ) => {
543+ const newEditorState = handleInlineStyle ( sameEditorState , character ) ;
544+ expect ( newEditorState ) . toEqual ( sameEditorState ) ;
545+ expect ( Draft . convertToRaw ( newEditorState . getCurrentContent ( ) ) ) . toEqual (
546+ before
547+ ) ;
548+ } ) ;
549+
550+ it ( "converts markdown to style or block type" , ( ) => {
533551 const newEditorState = handleInlineStyle ( editorState , character ) ;
534552 expect ( newEditorState ) . not . toEqual ( editorState ) ;
535553 expect ( Draft . convertToRaw ( newEditorState . getCurrentContent ( ) ) ) . toEqual (
0 commit comments