@@ -4,7 +4,7 @@ import { CodemirrorInlineEditor } from './editor';
44import type { EditorRef } from './types' ;
55import { expect } from 'chai' ;
66
7- function renderEditor ( text : string ) {
7+ function renderCodemirrorInlineEditor ( text : string ) {
88 const editorRef = React . createRef < EditorRef > ( ) ;
99 render ( < CodemirrorInlineEditor text = { text } ref = { editorRef } /> ) ;
1010 return editorRef ;
@@ -14,7 +14,7 @@ describe('Editor', function () {
1414 context ( 'CodemirrorInlineEditor' , function ( ) {
1515 let editorRef : React . RefObject < EditorRef > ;
1616 beforeEach ( function ( ) {
17- editorRef = renderEditor ( '{}' ) ;
17+ editorRef = renderCodemirrorInlineEditor ( '{}' ) ;
1818
1919 const lines = document . querySelectorAll ( '.cm-line' ) ;
2020 expect ( lines . length ) . to . equal ( 1 ) ;
@@ -35,6 +35,11 @@ describe('Editor', function () {
3535 expect ( lines [ 0 ] . textContent ) . to . equal ( '{' ) ;
3636 expect ( lines [ 1 ] . textContent ?. trim ( ) ) . to . equal ( '' ) ;
3737 expect ( lines [ 2 ] . textContent ) . to . equal ( '}' ) ;
38+
39+ // 2 new line characters as it it allows for new content to be added
40+ // between the opening and closing braces. and it also correctly
41+ // indents the cursor position with (2) spaces.
42+ expect ( editorRef . current ?. editorContents ) . to . equal ( '{\n \n}' ) ;
3843 } ) ;
3944
4045 it ( 'renders multi lines on {shift}+{enter}' , function ( ) {
@@ -46,6 +51,8 @@ describe('Editor', function () {
4651 expect ( lines [ 0 ] . textContent ) . to . equal ( '{' ) ;
4752 expect ( lines [ 1 ] . textContent ?. trim ( ) ) . to . equal ( '' ) ;
4853 expect ( lines [ 2 ] . textContent ) . to . equal ( '}' ) ;
54+
55+ expect ( editorRef . current ?. editorContents ) . to . equal ( '{\n \n}' ) ;
4956 } ) ;
5057 } ) ;
5158} ) ;
0 commit comments