             expect(files[0].mode).toEqual '?'
 
       it "returns an array of size 2 when there is an untracked file and an unstaged file", ->
-        spyOn(git, 'cmd').andCallFake () ->
+        spyOn(git, 'cmd').andCallFake ->
           if git.cmd.callCount is 2
             Promise.resolve "untracked.txt"
           else

      expect(git.getSubmodule(pathToRepoFile)).toBe undefined

    it "returns a submodule when given file is in a submodule of a project repo", ->
      spyOn(atom.project, 'getRepositories').andCallFake () -> [mockRepoWithSubmodule]
      expect(git.getSubmodule(pathToSubmoduleFile).getWorkingDirectory()).toEqual Path.get "~/some/submodule"

  describe "git.relativize", ->
    it "returns relativized filepath for files in repo", ->
      spyOn(atom.project, 'getRepositories').andCallFake () -> [mockRepo, mockRepoWithSubmodule]
      expect(git.relativize pathToRepoFile).toBe 'directory/file'
      expect(git.relativize pathToSubmoduleFile).toBe "file"

  describe "git.cmd", ->
    it "returns a promise", ->
      waitsForPromise ->
        git.cmd().then () -> expect(true).toBeTruthy()

  describe "git.add", ->
    it "calls git.cmd with ['add', '--all', {fileName}]", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve true
      waitsForPromise ->
        git.add(mockRepo, file: pathToSubmoduleFile).then (success) ->
          expect(git.cmd).toHaveBeenCalledWith(['add', '--all', pathToSubmoduleFile], cwd: mockRepo.getWorkingDirectory())

    it "calls git.cmd with ['add', '--all', '.'] when no file is specified", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve true
      waitsForPromise ->
        git.add(mockRepo).then (success) ->
          expect(git.cmd).toHaveBeenCalledWith(['add', '--all', '.'], cwd: mockRepo.getWorkingDirectory())

    it "calls git.cmd with ['add', '--update'...] when update option is true", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve true
      waitsForPromise ->
        git.add(mockRepo, update: true).then (success) ->
          expect(git.cmd).toHaveBeenCalledWith(['add', '--update', '.'], cwd: mockRepo.getWorkingDirectory())

  describe "git.reset", ->
    it "resets and unstages all files", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve true
      waitsForPromise ->
        git.reset(mockRepo).then () ->
          expect(git.cmd).toHaveBeenCalledWith ['reset', 'HEAD'], cwd: mockRepo.getWorkingDirectory()

  describe "git.stagedFiles", ->
    it "returns an empty array when there are no staged files", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve ''
      waitsForPromise ->
        git.stagedFiles(mockRepo)
        .then (files) ->
          expect(files.length).toEqual 0

    it "returns an array with size 1 when there is a staged file", ->
      spyOn(git, 'cmd').andCallFake () -> Promise.resolve("M\tsomefile.txt")
      waitsForPromise ->
        git.stagedFiles(mockRepo)
        .then (files) ->
          expect(files.length).toEqual 1

    it "returns an array with size 4 when there are 4 staged files", ->
      spyOn(git, 'cmd').andCallFake () ->
        Promise.resolve("M\tsomefile.txt\nA\tfoo.file\nD\tanother.text\nM\tagain.rb")
      waitsForPromise ->
        git.stagedFiles(mockRepo)


    describe "git.unstagedFiles and showUntracked: true", ->
      it "returns an array with size 1 when there is only an untracked file", ->
        spyOn(git, 'cmd').andCallFake ->
          if git.cmd.callCount is 2
            Promise.resolve "somefile.txt"
          else
