Always quit Atom realistically in integration specs

This commit is contained in:
Max Brunsfeld
2015-04-14 14:16:39 -07:00
parent d5ff7f26bf
commit ce7d0c161d
2 changed files with 12 additions and 2 deletions

View File

@@ -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)

View File

@@ -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