From d9500e6bcd6cde0dd290dbdfeb22ea1ae299e50e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 15 Jun 2012 16:24:49 -0600 Subject: [PATCH] Atom spec no longer closes all open windows This makes life easier when you're running the spec suite while actually using atom to edit itself. --- spec/app/atom-spec.coffee | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/app/atom-spec.coffee b/spec/app/atom-spec.coffee index 3949863c3..2eb49bc96 100644 --- a/spec/app/atom-spec.coffee +++ b/spec/app/atom-spec.coffee @@ -1,37 +1,32 @@ Atom = require 'atom' fs = require 'fs' +_ = require 'underscore' describe "Atom", -> - closeAllWindows = -> - window.close() for window in atom.windows - waitsFor "there to be no windows", -> - atom.windows.length == 0 - beforeEach -> spyOn(Atom.prototype, "setUpKeymap") describe ".open(path)", -> - beforeEach -> - closeAllWindows() + newWindow = null afterEach -> - closeAllWindows() + newWindow?.close() describe "when opening a file", -> it "displays it in a new window with the contents of the file loaded", -> filePath = null filePath = require.resolve 'fixtures/sample.txt' - expect(atom.windows.length).toBe 0 + previousWindowCount = atom.windows.length atom.open filePath waitsFor "window to open", -> - atom.windows.length > 0 + atom.windows.length > previousWindowCount runs -> - expect(atom.windows.length).toBe 1 - newWindow = atom.windows[0] + expect(atom.windows.length).toBe previousWindowCount + 1 + newWindow = _.last(atom.windows) expect(newWindow.rootView.activeEditor().buffer.getPath()).toEqual filePath expect(newWindow.rootView.activeEditor().buffer.getText()).toEqual fs.read(filePath)