Skip to content
Browse files

Code review: add testcase for nonempty invalid regex; remove unneeded

JS dependency.
  • Loading branch information...
1 parent 1328419 commit 74712d928dd4f042ce308b803aa38e8f25cccf12 @peterflynn peterflynn committed Dec 11, 2012
Showing with 12 additions and 2 deletions.
  1. +0 −1 test/SpecRunner.html
  2. +12 −1 test/spec/FindReplace-test.js
View
1 test/SpecRunner.html
@@ -38,7 +38,6 @@
<script src="../src/thirdparty/CodeMirror2/lib/codemirror.js"></script>
<script src="../src/thirdparty/CodeMirror2/lib/util/dialog.js"></script>
<script src="../src/thirdparty/CodeMirror2/lib/util/searchcursor.js"></script>
- <script src="../src/thirdparty/CodeMirror2/lib/util/search.js"></script>
<script src="../src/thirdparty/mustache/mustache.js"></script>
<script src="thirdparty/bootstrap2/js/bootstrap.min.js"></script>
View
13 test/spec/FindReplace-test.js
@@ -419,7 +419,7 @@ define(function (require, exports, module) {
expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}});
});
- it("should support case-insenseitive regexps via /.../i", function () {
+ it("should support case-insensitive regexps via /.../i", function () {
myEditor.setCursorPos(0, 0);
CommandManager.execute(Commands.EDIT_FIND);
@@ -438,6 +438,17 @@ define(function (require, exports, module) {
expectSelection({start: {line: LINE_FIRST_REQUIRE + 1, ch: 30}, end: {line: LINE_FIRST_REQUIRE + 1, ch: 33}});
});
+ it("shouldn't choke on invalid regexp", function () {
+ myEditor.setCursorPos(0, 0);
+
+ CommandManager.execute(Commands.EDIT_FIND);
+
+ // This is interpreted as a regexp (has both "/"es) but is invalid; should show error message
+ enterSearchText("/+/");
+ expect($(".CodeMirror-dialog .alert-message").length).toBe(1);
+ expectCursorAt({line: 0, ch: 0}); // no change
+ });
+
it("shouldn't choke on empty regexp", function () {
myEditor.setCursorPos(0, 0);

0 comments on commit 74712d9

Please sign in to comment.
Something went wrong with that request. Please try again.