From dcb9371c134a5748ee6cb2bdcfed6202011fb659 Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 7 Jan 2016 13:07:36 -0500 Subject: [PATCH] Test it. --- spec/git-repository-async-spec.js | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/spec/git-repository-async-spec.js b/spec/git-repository-async-spec.js index 70260fe49..ccfbfd100 100644 --- a/spec/git-repository-async-spec.js +++ b/spec/git-repository-async-spec.js @@ -16,9 +16,9 @@ function openFixture (fixture) { return GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', fixture)) } -function copyRepository () { +function copyRepository (name = 'working-dir') { const workingDirPath = temp.mkdirSync('atom-working-dir') - fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.copySync(path.join(__dirname, 'fixtures', 'git', name), workingDirPath) fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) return fs.realpathSync(workingDirPath) } @@ -299,17 +299,44 @@ describe('GitRepositoryAsync', () => { cleanPath = path.join(workingDirectory, 'other.txt') fs.writeFileSync(cleanPath, 'Full of text') fs.writeFileSync(newPath, '') + fs.writeFileSync(modifiedPath, 'making this path modified') newPath = fs.absolute(newPath) // specs could be running under symbol path. }) it('returns status information for all new and modified files', async () => { - fs.writeFileSync(modifiedPath, 'making this path modified') await repo.refreshStatus() expect(await repo.getCachedPathStatus(cleanPath)).toBeUndefined() expect(repo.isStatusNew(await repo.getCachedPathStatus(newPath))).toBe(true) expect(repo.isStatusModified(await repo.getCachedPathStatus(modifiedPath))).toBe(true) }) + + describe('in a repository with submodules', () => { + beforeEach(() => { + const workingDirectory = copyRepository('repo-with-submodules') + repo = GitRepositoryAsync.open(workingDirectory) + modifiedPath = path.join(workingDirectory, 'jstips', 'README.md') + newPath = path.join(workingDirectory, 'You-Dont-Need-jQuery', 'untracked.txt') + cleanPath = path.join(workingDirectory, 'jstips', 'CONTRIBUTING.md') + fs.writeFileSync(newPath, '') + fs.writeFileSync(modifiedPath, 'making this path modified') + newPath = fs.absolute(newPath) // specs could be running under symbol path. + + const reGit = (name) => { + fs.renameSync(path.join(workingDirectory, name, 'git.git'), path.join(workingDirectory, name, '.git')) + } + reGit('jstips') + reGit('You-Dont-Need-jQuery') + }) + + it('returns status information for all new and modified files', async () => { + await repo.refreshStatus() + + expect(await repo.getCachedPathStatus(cleanPath)).toBeUndefined() + expect(repo.isStatusNew(await repo.getCachedPathStatus(newPath))).toBe(true) + expect(repo.isStatusModified(await repo.getCachedPathStatus(modifiedPath))).toBe(true) + }) + }) }) describe('.isProjectAtRoot()', () => {