Skip to content

Commit c4593fb

Browse files
committed
cr fixes
1 parent 1b84570 commit c4593fb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/compass-editor/src/editor.spec.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CodemirrorInlineEditor } from './editor';
44
import type { EditorRef } from './types';
55
import { 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

Comments
 (0)