Avoid async code in more flaky tests
MODIFY
spec/results-view-spec.js
spec/results-view-spec.js
@@ -35,13 +35,15 @@ describe('ResultsView', () => {
return getResultsPane().refs.resultsView;
}
- function buildResultsView() {
+ function buildResultsView(options = {}) {
const FindOptions = require("../lib/find-options")
const ResultsModel = require("../lib/project/results-model")
const { Result } = ResultsModel
const ResultsView = require("../lib/project/results-view")
const model = new ResultsModel(new FindOptions({}), null)
const resultsView = new ResultsView({ model })
+
+ if (!options.empty) {
model.addResult("/a/b.txt", Result.create({
filePath: "/a/b.txt",
matches: [
@@ -66,6 +68,8 @@ describe('ResultsView', () => {
}
]
}))
+ }
+
return resultsView
}
@@ -660,11 +664,7 @@ describe('ResultsView', () => {
describe("when the results view is empty", () => {
it("ignores core:confirm and other commands for selecting results", async () => {
- projectFindView.findEditor.setText('thiswillnotmatchanythingintheproject');
- atom.commands.dispatch(projectFindView.element, 'core:confirm');
- await searchPromise;
- resultsView = getResultsView();
- await resultsView.heightInvalidationPromise;
+ const resultsView = buildResultsView({ empty: true });
atom.commands.dispatch(resultsView.element, 'core:confirm');
atom.commands.dispatch(resultsView.element, 'core:move-down');
atom.commands.dispatch(resultsView.element, 'core:move-up');
@@ -675,10 +675,8 @@ describe('ResultsView', () => {
});
it("won't show the preview-controls", async () => {
- projectFindView.findEditor.setText('thiswillnotmatchanythingintheproject');
- atom.commands.dispatch(projectFindView.element, 'core:confirm');
- await searchPromise;
- expect(getResultsPane().refs.previewControls.style.display).toBe('none');
+ const resultsPane = new ResultsPaneView();
+ expect(resultsPane.refs.previewControls.style.display).toBe('none');
});
});

Avoid async code in more flaky tests