diff --git a/spec/git-repository-async-spec.js b/spec/git-repository-async-spec.js index 900d81bfb..25623ae27 100644 --- a/spec/git-repository-async-spec.js +++ b/spec/git-repository-async-spec.js @@ -483,9 +483,10 @@ describe('GitRepositoryAsync', () => { describe('buffer events', () => { let repo + let workingDirectory beforeEach(() => { - const workingDirectory = copyRepository() + workingDirectory = copyRepository() atom.project.setPaths([workingDirectory]) // When the path is added to the project, the repository is refreshed. We @@ -512,10 +513,9 @@ describe('GitRepositoryAsync', () => { }) it('emits a status-changed event when a buffer is reloaded', async () => { + fs.writeFileSync(path.join(workingDirectory, 'other.txt'), 'changed') const editor = await atom.workspace.open('other.txt') - fs.writeFileSync(editor.getPath(), 'changed') - const statusHandler = jasmine.createSpy('statusHandler') repo.onDidChangeStatus(statusHandler) editor.getBuffer().reload() diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 3afd4da75..db42f3fc8 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -290,10 +290,11 @@ describe "GitRepository", -> expect(repo.isStatusNew(status)).toBe false describe "buffer events", -> - [editor] = [] + [editor, workingDirectory] = [] beforeEach -> - atom.project.setPaths([copyRepository()]) + workingDirectory = copyRepository() + atom.project.setPaths([workingDirectory]) waitsForPromise -> atom.workspace.open('other.txt').then (o) -> editor = o @@ -310,13 +311,16 @@ describe "GitRepository", -> it "emits a status-changed event when a buffer is reloaded", -> fs.writeFileSync(editor.getPath(), 'changed') - statusHandler = jasmine.createSpy('statusHandler') - atom.project.getRepositories()[0].onDidChangeStatus statusHandler - editor.getBuffer().reload() - expect(statusHandler.callCount).toBe 1 - expect(statusHandler).toHaveBeenCalledWith {path: editor.getPath(), pathStatus: 256} - editor.getBuffer().reload() - expect(statusHandler.callCount).toBe 1 + waitsForPromise -> + atom.workspace.open(path.join(workingDirectory, 'other.txt')).then (o) -> editor = o + runs -> + statusHandler = jasmine.createSpy('statusHandler') + atom.project.getRepositories()[0].onDidChangeStatus statusHandler + editor.getBuffer().reload() + expect(statusHandler.callCount).toBe 1 + expect(statusHandler).toHaveBeenCalledWith {path: editor.getPath(), pathStatus: 256} + editor.getBuffer().reload() + expect(statusHandler.callCount).toBe 1 it "emits a status-changed event when a buffer's path changes", -> fs.writeFileSync(editor.getPath(), 'changed')