diff --git a/spec/atom-environment-spec.coffee b/spec/atom-environment-spec.coffee index 8a3e4e0fb..03d65a3d6 100644 --- a/spec/atom-environment-spec.coffee +++ b/spec/atom-environment-spec.coffee @@ -322,6 +322,44 @@ describe "AtomEnvironment", -> expect(atom2.textEditors.getGrammarOverride(editor)).toBe('text.plain') atom2.destroy() + describe "deserialization failures", -> + + it "propagates project state restoration failures", -> + spyOn(atom.project, 'deserialize').andCallFake => + err = new Error('deserialization failure') + err.missingProjectPaths = ['/foo'] + Promise.reject(err) + spyOn(atom.notifications, 'addError') + + waitsForPromise -> atom.deserialize({project: 'should work'}) + runs -> + expect(atom.notifications.addError).toHaveBeenCalledWith 'Unable to open project directory', + {description: 'Project directory `/foo` is no longer on disk.'} + + it "accumulates and reports two errors with one notification", -> + spyOn(atom.project, 'deserialize').andCallFake => + err = new Error('deserialization failure') + err.missingProjectPaths = ['/foo', '/wat'] + Promise.reject(err) + spyOn(atom.notifications, 'addError') + + waitsForPromise -> atom.deserialize({project: 'should work'}) + runs -> + expect(atom.notifications.addError).toHaveBeenCalledWith 'Unable to open 2 project directories', + {description: 'Project directories `/foo` and `/wat` are no longer on disk.'} + + it "accumulates and reports three+ errors with one notification", -> + spyOn(atom.project, 'deserialize').andCallFake => + err = new Error('deserialization failure') + err.missingProjectPaths = ['/foo', '/wat', '/stuff', '/things'] + Promise.reject(err) + spyOn(atom.notifications, 'addError') + + waitsForPromise -> atom.deserialize({project: 'should work'}) + runs -> + expect(atom.notifications.addError).toHaveBeenCalledWith 'Unable to open 4 project directories', + {description: 'Project directories `/foo`, `/wat`, `/stuff`, and `/things` are no longer on disk.'} + describe "openInitialEmptyEditorIfNecessary", -> describe "when there are no paths set", -> beforeEach ->