Merge pull request #9529 from atom/as-fix-bad-fat-arrow

Use fat arrow when showing errors in CommandInstaller
This commit is contained in:
Nathan Sobo
2015-11-11 12:02:36 -07:00
2 changed files with 38 additions and 3 deletions

View File

@@ -20,10 +20,45 @@ 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"
})
it "shows a success dialog when installing commands interactively succeeds", ->
appDelegate = jasmine.createSpyObj("appDelegate", ["confirm"])
installer = new CommandInstaller("2.0.2", appDelegate)
spyOn(installer, "installAtomCommand").andCallFake (__, callback) -> callback()
spyOn(installer, "installApmCommand").andCallFake (__, callback) -> callback()
installer.installShellCommandsInteractively()
expect(appDelegate.confirm).toHaveBeenCalledWith({
message: "Commands installed."
detailedMessage: "The shell commands `atom` and `apm` are installed."
})
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