Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add unit test for remembering regexp state for Find Next after search…

… bar is closed.

Also refactors out some common code from the case sensitivity test.
  • Loading branch information...
commit 7b1f77d719715ef8064d2858ee0a808b76f99e8a 1 parent d5f3022
Narciso Jaramillo njx authored
Showing with 43 additions and 10 deletions.
  1. +43 −10 test/spec/FindReplace-test.js
53 test/spec/FindReplace-test.js
View
@@ -107,6 +107,16 @@ define(function (require, exports, module) {
}
expect(actualHighlights.length).toEqual(expectedDOMHighlightCount);
}
+ function expectFindNextSelections(selections) {
+ var i;
+ for (i = 0; i < selections.length; i++) {
+ expectSelection(selections[i]);
+ twCommandManager.execute(Commands.EDIT_FIND_NEXT);
+ }
+
+ // next find should wraparound
+ expectSelection(selections[0]);
+ }
function getSearchBar() {
@@ -422,15 +432,7 @@ define(function (require, exports, module) {
waitsForSearchBarClose();
runs(function () {
- expectSelection(capitalFooSelections[0]);
- twCommandManager.execute(Commands.EDIT_FIND_NEXT);
- expectSelection(capitalFooSelections[1]);
- twCommandManager.execute(Commands.EDIT_FIND_NEXT);
- expectSelection(capitalFooSelections[2]);
-
- // next find should wraparound since it should skip the lowercase "foo()"
- twCommandManager.execute(Commands.EDIT_FIND_NEXT);
- expectSelection(capitalFooSelections[0]);
+ expectFindNextSelections(capitalFooSelections);
});
});
@@ -695,6 +697,37 @@ define(function (require, exports, module) {
expectSelection(expectedSelections[0]);
});
+
+ it("should Find Next after search bar closed, remembering last used regexp", function () {
+ var expectedSelections = [
+ {start: {line: LINE_FIRST_REQUIRE + 1, ch: 8}, end: {line: LINE_FIRST_REQUIRE + 1, ch: 11}},
+ {start: {line: LINE_FIRST_REQUIRE + 1, ch: 31}, end: {line: LINE_FIRST_REQUIRE + 1, ch: 34}},
+ {start: {line: LINE_FIRST_REQUIRE + 2, ch: 8}, end: {line: LINE_FIRST_REQUIRE + 2, ch: 11}},
+ {start: {line: LINE_FIRST_REQUIRE + 2, ch: 31}, end: {line: LINE_FIRST_REQUIRE + 2, ch: 34}}
+ ];
+
+ runs(function () {
+ myEditor.setCursorPos(0, 0);
+
+ twCommandManager.execute(Commands.EDIT_FIND);
+
+ toggleRegexp(true);
+ enterSearchText("Ba.");
+ pressEscape();
+ expectHighlightedMatches([]);
+ });
+
+ waitsForSearchBarClose();
+
+ runs(function () {
+ expectFindNextSelections(expectedSelections);
+
+ // explicitly clean up since we closed the search bar
+ twCommandManager.execute(Commands.EDIT_FIND);
+ toggleRegexp(false);
+ });
+ });
+
it("toggling regexp option should update results immediately", function () {
myEditor.setCursorPos(0, 0);
@@ -745,7 +778,7 @@ define(function (require, exports, module) {
expectHighlightedMatches(expectedSelections);
expectSelection(expectedSelections[0]);
});
-
+
it("shouldn't choke on invalid regexp", function () {
myEditor.setCursorPos(0, 0);
Please sign in to comment.
Something went wrong with that request. Please try again.