Add spec for invalid settings notification

This commit is contained in:
Kevin Sawicki
2015-03-04 11:18:10 -08:00
parent f02fa4a245
commit 7a3065e0fb
4 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
{
"name": "package-with-invalid-settings",
"version": "1.0.0"
}

View File

@@ -0,0 +1 @@
><

View File

@@ -239,6 +239,19 @@ describe "PackageManager", ->
expect(addErrorHandler.callCount).toBe 1
expect(addErrorHandler.argsForCall[0][0].message).toContain("Failed to load a package-with-invalid-grammar package grammar")
it "adds a notification when the settings are invalid", ->
addErrorHandler = jasmine.createSpy()
atom.notifications.onDidAddNotification(addErrorHandler)
expect(-> atom.packages.activatePackage('package-with-invalid-settings')).not.toThrow()
waitsFor ->
addErrorHandler.callCount > 0
runs ->
expect(addErrorHandler.callCount).toBe 1
expect(addErrorHandler.argsForCall[0][0].message).toContain("Failed to load the package-with-invalid-settings package settings")
describe "when the package has no main module", ->
it "does not throw an exception", ->
spyOn(console, "error")

View File

@@ -324,7 +324,7 @@ class Package
ScopedProperties.load settingsPath, (error, settings) =>
if error?
detail = "#{error.message} in #{settingsPath}"
stack += "#{error.stack}\n at #{settingsPath}:1:1"
stack = "#{error.stack}\n at #{settingsPath}:1:1"
atom.notifications.addFatalError("Failed to load the #{@name} package settings", {stack, detail, dismissable: true})
else
@settings.push(settings)