Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 3ec6b30

Browse files
authored
Merge pull request #1079 from atom/remove-async-test-helpers
Remove async test helpers
2 parents aea59a5 + cf19f70 commit 3ec6b30

File tree

8 files changed

+2
-48
lines changed

8 files changed

+2
-48
lines changed

spec/async-spec-helpers.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
11
/** @babel */
22

3-
export function beforeEach (fn) {
4-
global.beforeEach(function () {
5-
const result = fn()
6-
if (result instanceof Promise) {
7-
waitsForPromise(() => result)
8-
}
9-
})
10-
}
11-
12-
export function afterEach (fn) {
13-
global.afterEach(function () {
14-
const result = fn()
15-
if (result instanceof Promise) {
16-
waitsForPromise(() => result)
17-
}
18-
})
19-
}
20-
21-
['it', 'fit', 'ffit', 'fffit'].forEach(function (name) {
22-
module.exports[name] = function (description, fn) {
23-
global[name](description, function () {
24-
const result = fn()
25-
if (result instanceof Promise) {
26-
waitsForPromise(() => result)
27-
}
28-
})
29-
}
30-
})
31-
323
export async function conditionPromise (condition) {
334
const startTime = Date.now()
345

@@ -45,18 +16,8 @@ export async function conditionPromise (condition) {
4516
}
4617
}
4718

48-
export function timeoutPromise (timeout) {
19+
function timeoutPromise (timeout) {
4920
return new Promise(function (resolve) {
5021
global.setTimeout(resolve, timeout)
5122
})
5223
}
53-
54-
function waitsForPromise (fn) {
55-
const promise = fn()
56-
global.waitsFor('spec promise to resolve', function (done) {
57-
promise.then(done, function (error) {
58-
jasmine.getEnv().currentSpec.fail(error)
59-
done()
60-
})
61-
})
62-
}

spec/find-spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const {it, fit, ffit, beforeEach, afterEach} = require('./async-spec-helpers') // eslint-disable-line no-unused-vars
2-
31
const BufferSearch = require('../lib/buffer-search')
42
const EmbeddedEditorItem = require('./item/embedded-editor-item')
53
const DeferredEditorItem = require('./item/deferred-editor-item');

spec/find-view-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @babel */
22

33
const path = require("path");
4-
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
54

65
describe("FindView", () => {
76
let workspaceElement, editorView, editor, findView, activationPromise;

spec/project-find-view-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const dedent = require('dedent');
77
const {TextBuffer} = require('atom');
88
const ResultsPaneView = require('../lib/project/results-pane');
99
const etch = require('etch');
10-
const {beforeEach, it, fit, ffit, fffit, conditionPromise} = require('./async-spec-helpers')
10+
const {conditionPromise} = require('./async-spec-helpers');
1111

1212
for (const ripgrep of [false, true]) {
1313
describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {

spec/result-row-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
MatchRow,
88
ResultRowGroup
99
} = require("../lib/project/result-row");
10-
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
1110

1211
describe("ResultRowGroup", () => {
1312
const lines = (new Array(18)).fill().map((x, i) => `line-${i}`)

spec/results-model-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const path = require("path");
44
const ResultsModel = require("../lib/project/results-model");
55
const FindOptions = require("../lib/find-options");
6-
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
76

87
describe("ResultsModel", () => {
98
let editor, resultsModel, reporterSpy;

spec/results-view-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const ResultsPaneView = require('../lib/project/results-pane');
99
const getIconServices = require('../lib/get-icon-services');
1010
const DefaultFileIcons = require('../lib/default-file-icons');
1111
const {Disposable} = require('atom')
12-
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
1312

1413
global.beforeEach(function() {
1514
this.addMatchers({

spec/select-next-spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const path = require('path');
44
const SelectNext = require('../lib/select-next');
55
const dedent = require('dedent');
6-
const {beforeEach, it, fit, ffit, fffit} = require('./async-spec-helpers')
76

87
describe("SelectNext", () => {
98
let workspaceElement, editorElement, editor;

0 commit comments

Comments
 (0)