From 55cc08215dd08ba053824fa4e68b5f759b3239fb Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 10 Nov 2015 15:23:47 -0500 Subject: [PATCH] Be even less racy. --- spec/git-repository-async-spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/git-repository-async-spec.js b/spec/git-repository-async-spec.js index 0e94d360a..38ee1b8bc 100644 --- a/spec/git-repository-async-spec.js +++ b/spec/git-repository-async-spec.js @@ -307,11 +307,11 @@ describe('GitRepositoryAsync-js', () => { // When the path is added to the project, the repository is refreshed. We // need to wait for that to complete before the tests continue so that - // we're in a known state. - let repository = atom.project.getRepositories()[0].async - let statusHandler = jasmine.createSpy('statusHandler') - repository.onDidChangeStatuses(statusHandler) - waitsFor(() => statusHandler.callCount > 0) + // we're in a known state. *But* it's really hard to observe that from the + // outside in a non-racy fashion. So let's refresh again and wait for it + // to complete before we continue. + let repository = atom.project.getRepositories()[0] + waitsForPromise(() => repository.refreshStatus()) }) asyncIt('emits a status-changed event when a buffer is saved', async () => { @@ -391,10 +391,10 @@ describe('GitRepositoryAsync-js', () => { beforeEach(() => { atom.project.setPaths([copyRepository()]) - let repository = atom.project.getRepositories()[0].async - let statusHandler = jasmine.createSpy('statusHandler') - repository.onDidChangeStatuses(statusHandler) - waitsFor(() => statusHandler.callCount > 0) + // See the comment in the 'buffer events' beforeEach for why we need to do + // this. + let repository = atom.project.getRepositories()[0] + waitsForPromise(() => repository.refreshStatus()) }) afterEach(() => {