Fix the specs.

This commit is contained in:
joshaber
2016-03-25 13:36:38 -04:00
parent aee053dc10
commit 39dcd59994
2 changed files with 16 additions and 12 deletions

View File

@@ -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()

View File

@@ -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')