Skip to content

Commit

Permalink
test: nested bracket indent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Jan 4, 2022
1 parent 063f5e9 commit a2483b2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/src/tests/TextEditorTextInputTestCase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,36 @@ class TextEditorTextInputTestCase extends Test {
Assert.equals(-1, _textEditor.selectionEndCharIndex);
}

public function testNewLineAfterNestedBracketOpenIncreasesIndent():Void {
_textEditor.brackets = [["{", "}"]];
_textEditor.text = "hello {\n\tworld {";
_textEditor.stage.focus = _textEditor;
_textEditor.setSelection(1, 8, 1, 8);
_textEditor.stage.focus.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, true, 0, Keyboard.ENTER));
Assert.equals("hello {\n\tworld {\n\t\t", _textEditor.text);
Assert.equals(2, _textEditor.caretLineIndex);
Assert.equals(2, _textEditor.caretCharIndex);
Assert.equals(-1, _textEditor.selectionStartLineIndex);
Assert.equals(-1, _textEditor.selectionStartCharIndex);
Assert.equals(-1, _textEditor.selectionEndLineIndex);
Assert.equals(-1, _textEditor.selectionEndCharIndex);
}

public function testNestedBracketCloseAfterNewLineDecreasesIndent():Void {
_textEditor.brackets = [["{", "}"]];
_textEditor.text = "hello {\n\tworld {\n\t\t";
_textEditor.stage.focus = _textEditor;
_textEditor.setSelection(2, 2, 2, 2);
_textEditor.dispatchEvent(new TextEvent(TextEvent.TEXT_INPUT, false, false, "}"));
Assert.equals("hello {\n\tworld {\n\t}", _textEditor.text);
Assert.equals(2, _textEditor.caretLineIndex);
Assert.equals(2, _textEditor.caretCharIndex);
Assert.equals(-1, _textEditor.selectionStartLineIndex);
Assert.equals(-1, _textEditor.selectionStartCharIndex);
Assert.equals(-1, _textEditor.selectionEndLineIndex);
Assert.equals(-1, _textEditor.selectionEndCharIndex);
}

public function testToggleLineCommentOn():Void {
_textEditor.lineComment = "//";
_textEditor.text = "hello";
Expand Down

0 comments on commit a2483b2

Please sign in to comment.