diff --git a/spec/integration/helpers/start-atom.coffee b/spec/integration/helpers/start-atom.coffee index 4be2efab8..798853eab 100644 --- a/spec/integration/helpers/start-atom.coffee +++ b/spec/integration/helpers/start-atom.coffee @@ -94,6 +94,15 @@ buildAtomClient = (args, env) -> ]), env: extend({}, process.env, env)) done() + .addCommand "dispatchCommand", (command, done) -> + @execute "atom.commands.dispatch(document.activeElement, '#{command}')" + .call(done) + + .addCommand "simulateQuit", (done) -> + @execute -> atom.unloadEditorWindow() + .execute -> require("remote").require("app").emit("before-quit") + .call(done) + module.exports = (args, env, fn) -> [chromedriver, chromedriverLogs, chromedriverExit] = [] @@ -119,6 +128,7 @@ module.exports = (args, env, fn) -> waitsFor("webdriver to finish", (done) -> finish = once -> client + .simulateQuit() .end() .then(-> chromedriver.kill()) .then(chromedriverExit.then( @@ -133,7 +143,7 @@ module.exports = (args, env, fn) -> client = buildAtomClient(args, env) client.on "error", (err) -> - jasmine.getEnv().currentSpec.fail(JSON.stringify(err)) + jasmine.getEnv().currentSpec.fail(new Error(err.response?.body?.value?.message)) finish() fn(client.init()).then(finish) diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index 5c18255a8..d34330b9e 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -36,6 +36,7 @@ describe "Starting Atom", -> .keys("Hello!") .execute -> atom.workspace.getActiveTextEditor().getText() .then ({value}) -> expect(value).toBe "Hello!" + .dispatchCommand("editor:delete-line") describe "when there is already a window open", -> it "reuses that window when opening files, but not when opening directories", -> @@ -75,7 +76,6 @@ describe "Starting Atom", -> .waitForPaneItemCount(0, 3000) .execute -> atom.workspace.open() .waitForPaneItemCount(1, 3000) - .execute -> atom.unloadEditorWindow() runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) -> client