               expect(addDialog.errorMessage.textContent).toContain 'already exists'
               expect(addDialog.element).toHaveClass('error')
               expect(atom.workspace.getModalPanels()[0]).toBe addPanel
-              expect(handlers['file-created'][0]).not.toHaveBeenCalled()
+              expect(callback).not.toHaveBeenCalled()
 
           describe "when the project has no path", ->
             it "adds a file and closes the dialog", ->


      describe "when the file is deleted", ->
        it "updates the style of the directory", ->
          handlers = treeView.emitter.handlersByEventName
          treeView.onEntryDeleted ->
          spyOn(handlers['entry-deleted'], '0')

          expect(treeView.selectedEntry().getPath()).toContain(path.join('dir2', 'new2'))
          dirView = findDirectoryContainingText(treeView.roots[0], 'dir2')
          expect(dirView).not.toBeNull()

          expect(atom.notifications.getNotifications()[0].getDetail()).toContain 'ENOENT: no such file or directory'

    describe "tree-view:add-file", ->
      [addPanel, addDialog, callback] = []

      beforeEach ->
        jasmine.attachToDOM(workspaceElement)
        callback = jasmine.createSpy("onFileCreated")
        treeView.onFileCreated(callback)

        waitsForFileToOpen ->
          fileView.dispatchEvent(new MouseEvent('click', {bubbles: true, detail: 1}))
