Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
icecream17 authored Jun 23, 2024
1 parent 024fae4 commit fd6f880
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/find-and-replace/spec/find-view-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe("FindView", () => {
}

// usage:
// getResultDecorations(editor, "current-result") --> length = number of currently selected results (usually 1)
// getResultDecorations(editor, "current-result") --> length = number of currently selected results (usually 1, after a
// atom.commands.dispatch(findView.findEditor.element, "core:confirm");)
// getResultDecorations(editor, "find-result") --> length = number of results that are not currently selected (usually = # results - 1)
function getResultDecorations(editor, clazz) {
const result = [];
Expand Down Expand Up @@ -463,16 +464,22 @@ describe("FindView", () => {
});

it("finds the whole words even when the word starts or ends with a non-word character", () => {
// Arguably, a non-symbol doesn't form a whole word when surrounded by the same non-symbols,
// but the current code doesn't check for that.
findView.findEditor.setText("-");
atom.commands.dispatch(findView.findEditor.element, "core:confirm");
expect(getResultDecorations(editor, "find-result")).toHaveLength(7);
expect(getResultDecorations(editor, "current-result")).toHaveLength(1);

findView.findEditor.setText("-word");
atom.commands.dispatch(findView.findEditor.element, "core:confirm");
expect(editor.getSelectedBufferRange()).toEqual([[2, 5], [2, 10]]);

// The cursor is on line 2 because of ^^ so the first find is on line 4
findView.findEditor.setText("whole-");
atom.commands.dispatch(findView.findEditor.element, "core:confirm");
expect(editor.getSelectedBufferRange()).toEqual([[4, 0], [4, 6]]);
atom.commands.dispatch(findView.findEditor.element, "core:confirm");
expect(editor.getSelectedBufferRange()).toEqual([[2, 0], [2, 6]]);
});

Expand Down

0 comments on commit fd6f880

Please sign in to comment.