From 035429b7bc6fb9e812dc573e06d7c79b2feea9a9 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 4 Sep 2015 11:22:11 -0600 Subject: [PATCH] Wait for fakeSearch to be defined in spec --- spec/workspace-spec.coffee | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 9cbcea48f..a7d562533 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -1122,11 +1122,16 @@ describe "Workspace", -> it "can be cancelled when the object returned by scan() has its cancel() method invoked", -> thenable = atom.workspace.scan /aaaa/, -> - expect(fakeSearch.cancelled).toBe(undefined) - thenable.cancel() - expect(fakeSearch.cancelled).toBe(true) - resultOfPromiseSearch = null + + waitsFor 'fakeSearch to be defined', -> fakeSearch? + + runs -> + expect(fakeSearch.cancelled).toBe(undefined) + thenable.cancel() + expect(fakeSearch.cancelled).toBe(true) + + waitsForPromise -> thenable.then (promiseResult) -> resultOfPromiseSearch = promiseResult