This commit is contained in:
Daniel Hengeveld
2015-10-15 16:51:39 +02:00
parent 8e744502fa
commit b566e47a08
2 changed files with 29 additions and 7 deletions

View File

@@ -34,18 +34,31 @@ fdescribe "GitRepositoryAsync", ->
expect(repo.repo).toBe null
describe ".getPath()", ->
it "returns the repository path for a .git directory path", ->
# XXX HEAD isn't a git directory.. what's this spec supposed to be about?
xit "returns the repository path for a .git directory path", ->
# Rejects as malformed
repo = GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', 'master.git', 'HEAD'))
waitsForPromise ->
repo.getPath
onSuccess = jasmine.createSpy('onSuccess')
runs ->
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
waitsForPromise ->
repo.getPath().then(onSuccess)
runs ->
expectedPath = path.join(__dirname, 'fixtures', 'git', 'master.git')
expect(onSuccess.mostRecentCall.args[0]).toBe(expectedPath)
it "returns the repository path for a repository path", ->
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'master.git'))
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
repo = GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', 'master.git'))
onSuccess = jasmine.createSpy('onSuccess')
waitsForPromise ->
repo.getPath().then(onSuccess)
runs ->
expectedPath = path.join(__dirname, 'fixtures', 'git', 'master.git')
expect(onSuccess.mostRecentCall.args[0]).toBe(expectedPath)
xdescribe ".isPathIgnored(path)", ->
it "returns true for an ignored path", ->

View File

@@ -13,11 +13,20 @@ module.exports = class GitRepositoryAsync {
// this could be replaced with a function
this._opening = true
// Do I use this outside of tests?
openPromise.then( (repo) => {
this.repo = repo
this._opening = false
}).catch( (e) => {
this._opening = false
})
this.repoPromise = openPromise
}
getPath () {
return this.repoPromise.then( (repo) => {
return Promise.resolve(repo.path().replace(/\/$/, ''))
})
}
}