@@ -96,17 +96,17 @@ describe('handleNewCodeBlock', () => {
9696 } ]
9797 } ;
9898 const contentState = Draft . convertFromRaw ( beforeRawContentState ) ;
99- const selection = new SelectionState ( {
100- anchorKey : 'item1' ,
101- anchorOffset : 21 ,
102- focusKey : 'item1' ,
103- focusOffset : 21 ,
104- isBackward : false ,
105- hasFocus : true
106- } ) ;
107- const editorState = EditorState . forceSelection (
108- EditorState . createWithContent ( contentState ) , selection ) ;
10999 it ( 'adds new line inside code block' , ( ) => {
100+ const selection = new SelectionState ( {
101+ anchorKey : 'item1' ,
102+ anchorOffset : 21 ,
103+ focusKey : 'item1' ,
104+ focusOffset : 21 ,
105+ isBackward : false ,
106+ hasFocus : true
107+ } ) ;
108+ const editorState = EditorState . forceSelection (
109+ EditorState . createWithContent ( contentState ) , selection ) ;
110110 const newEditorState = handleNewCodeBlock ( editorState ) ;
111111 expect ( newEditorState ) . not . to . equal ( editorState ) ;
112112 expect (
@@ -115,6 +115,25 @@ describe('handleNewCodeBlock', () => {
115115 afterRawContentState
116116 ) ;
117117 } ) ;
118+ it ( 'does not add new line even inside code block' , ( ) => {
119+ const selection = new SelectionState ( {
120+ anchorKey : 'item1' ,
121+ anchorOffset : 10 ,
122+ focusKey : 'item1' ,
123+ focusOffset : 10 ,
124+ isBackward : false ,
125+ hasFocus : true
126+ } ) ;
127+ const editorState = EditorState . forceSelection (
128+ EditorState . createWithContent ( contentState ) , selection ) ;
129+ const newEditorState = handleNewCodeBlock ( editorState ) ;
130+ expect ( newEditorState ) . to . equal ( editorState ) ;
131+ expect (
132+ Draft . convertToRaw ( newEditorState . getCurrentContent ( ) )
133+ ) . to . deep . equal (
134+ beforeRawContentState
135+ ) ;
136+ } ) ;
118137 } ) ;
119138
120139 describe ( 'in unstyled block without three backquotes' , ( ) => {
0 commit comments