Remove reliance on class names in specs
MODIFY
spec/find-view-spec.js
spec/find-view-spec.js
@@ -1414,7 +1414,7 @@ describe("FindView", () => {
describe("when the replace next button is pressed", () => {
it("replaces the match after the cursor and selects the next match", () => {
- findView[0].querySelector(".btn-next").click();
+ findView.replaceNextButton.click();
expect(findView.resultCounter.text()).toEqual("2 of 5");
expect(editor.lineTextForBufferRow(2)).toBe(" if (cats.length <= 1) return items;");
expect(editor.getSelectedBufferRange()).toEqual([[2, 33], [2, 38]]);
@@ -1447,7 +1447,7 @@ describe("FindView", () => {
describe("replace all", () => {
describe("when the replace all button is pressed", () => {
it("replaces all matched text", () => {
- findView[0].querySelector(".btn-all").click();
+ findView.replaceAllButton.click();
expect(findView.resultCounter.text()).toEqual("no results");
expect(editor.getText()).not.toMatch(/items/);
expect(editor.getText().match(/\bcats\b/g)).toHaveLength(6);
@@ -1455,7 +1455,7 @@ describe("FindView", () => {
});
it("all changes are undoable in one transaction", () => {
- findView[0].querySelector(".btn-all").click();
+ findView.replaceAllButton.click();
editor.undo();
expect(editor.getText()).not.toMatch(/\bcats\b/g);
});

MODIFY
spec/results-view-spec.js
spec/results-view-spec.js
@@ -8,7 +8,7 @@ const FileIcons = require('../lib/file-icons');
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
describe('ResultsView', () => {
- let pack, projectFindView, resultsView, searchPromise, workspaceElement;
+ let projectFindView, resultsView, searchPromise, workspaceElement;
function getExistingResultsPane() {
let pane = atom.workspace.paneForURI(ResultsPaneView.URI);
@@ -690,7 +690,7 @@ describe('ResultsView', () => {
atom.commands.dispatch(projectFindView.element, 'core:confirm');
await searchPromise;
- const resultsView = getResultsView();
+ resultsView = getResultsView();
resultsView.selectFirstResult();
_.times(2, () => atom.commands.dispatch(resultsView.element, 'core:move-down'));
@@ -703,10 +703,9 @@ describe('ResultsView', () => {
it("copies the selected file path to clipboard", async () => {
projectFindView.findEditor.setText('items');
atom.commands.dispatch(projectFindView.element, 'core:confirm');
-
await searchPromise;
- const resultsView = getResultsView();
+ resultsView = getResultsView();
resultsView.selectFirstResult();
resultsView.collapseResult();
@@ -733,9 +732,9 @@ describe('ResultsView', () => {
projectFindView.findEditor.setText('i');
atom.commands.dispatch(projectFindView.element, 'core:confirm');
-
await searchPromise;
- let resultsView = getResultsView();
+
+ resultsView = getResultsView();
let fileIconClasses = Array.from(resultsView.find('.path-details .icon')).map(el => el.className);
expect(fileIconClasses).toContain('first-icon-class second-icon-class icon');
expect(fileIconClasses).toContain('third-icon-class fourth-icon-class icon');
@@ -766,4 +765,4 @@ function buildMouseEvent(type, properties) {
Object.defineProperty(event, 'srcObject', {get() { return properties.target; }});
}
return event;
-};
+}

MODIFY
spec/select-next-spec.js
spec/select-next-spec.js
@@ -6,7 +6,7 @@ const dedent = require('dedent');
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
describe("SelectNext", () => {
- let workspaceElement, editorElement, editor, promise;
+ let workspaceElement, editorElement, editor;
beforeEach(async () => {
workspaceElement = atom.views.getView(atom.workspace);

Remove reliance on class names in specs