Make sure showing errors works correctly

This commit is contained in:
Antonio Scandurra
2015-11-11 18:18:55 +01:00
parent 24e64ee9e1
commit 60841e574a
2 changed files with 25 additions and 3 deletions

View File

@@ -20,10 +20,32 @@ describe "CommandInstaller on #darwin", ->
spyOn(CommandInstaller::, 'getResourcesDirectory').andReturn(resourcesPath)
spyOn(CommandInstaller::, 'getInstallDirectory').andReturn(installationPath)
it "shows an error dialog when installing commands interactively fails", ->
appDelegate = jasmine.createSpyObj("appDelegate", ["confirm"])
installer = new CommandInstaller("2.0.2", appDelegate)
spyOn(installer, "installAtomCommand").andCallFake (__, callback) -> callback(new Error("an error"))
installer.installShellCommandsInteractively()
expect(appDelegate.confirm).toHaveBeenCalledWith({
message: "Failed to install shell commands"
detailedMessage: "an error"
})
appDelegate.confirm.reset()
installer.installAtomCommand.andCallFake (__, callback) -> callback()
spyOn(installer, "installApmCommand").andCallFake (__, callback) -> callback(new Error("another error"))
installer.installShellCommandsInteractively()
expect(appDelegate.confirm).toHaveBeenCalledWith({
message: "Failed to install shell commands"
detailedMessage: "another error"
})
describe "when using a stable version of atom", ->
beforeEach ->
confirm = ->
installer = new CommandInstaller("2.0.2", confirm)
installer = new CommandInstaller("2.0.2")
it "symlinks the atom command as 'atom'", ->
installedAtomPath = path.join(installationPath, 'atom')

View File

@@ -35,7 +35,7 @@ class CommandInstaller
process.resourcesPath
installShellCommandsInteractively: ->
showErrorDialog = (error) ->
showErrorDialog = (error) =>
@applicationDelegate.confirm
message: "Failed to install shell commands"
detailedMessage: error.message