Extract timeoutPromise into async-spec-helpers

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra
2016-08-12 17:46:12 +02:00
committed by Nathan Sobo
parent 82f0003302
commit 87d684132c
3 changed files with 8 additions and 13 deletions

View File

@@ -48,6 +48,12 @@ export function conditionPromise (condition) {
})
}
export function timeoutPromise (timeout) {
return new Promise(function (resolve) {
global.setTimeout(resolve, timeout)
})
}
function waitsForPromise (fn) {
const promise = fn()
// This timeout is 3 minutes. We need to bump it back down once we fix

View File

@@ -7,6 +7,7 @@ import fs from 'fs-plus'
import path from 'path'
import AtomApplication from '../../src/main-process/atom-application'
import parseCommandLine from '../../src/main-process/parse-command-line'
import {timeoutPromise} from '../async-spec-helpers'
const ATOM_RESOURCE_PATH = path.resolve(__dirname, '..', '..')
@@ -271,7 +272,7 @@ describe('AtomApplication', function () {
await window1.loadedPromise
// wait a bit just to make sure we don't pass due to querying the render process before it loads
await getTimeoutPromise(1000)
await timeoutPromise(1000)
const itemCount = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {
sendBackToMainProcess(atom.workspace.getActivePane().getItems().length)
@@ -399,12 +400,6 @@ describe('AtomApplication', function () {
})
}
function getTimeoutPromise (timeout) {
return new Promise(function (resolve) {
global.setTimeout(resolve, timeout)
})
}
function clearElectronSession () {
return new Promise(function (resolve) {
electron.session.defaultSession.clearStorageData(function () {

View File

@@ -5085,12 +5085,6 @@ describe('TextEditorComponent', function () {
}
}
function timeoutPromise (timeout) {
return new Promise(function (resolve) {
window.setTimeout(resolve, timeout)
})
}
function nextAnimationFramePromise () {
return new Promise(function (resolve) {
window.requestAnimationFrame(resolve)