2012-04-03 21:33:08 +04:00
|
|
|
Atom = require 'atom'
|
2011-12-16 02:13:34 +04:00
|
|
|
fs = require 'fs'
|
2012-06-16 02:24:49 +04:00
|
|
|
_ = require 'underscore'
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2012-04-03 21:33:08 +04:00
|
|
|
describe "Atom", ->
|
2012-04-04 04:21:13 +04:00
|
|
|
beforeEach ->
|
|
|
|
spyOn(Atom.prototype, "setUpKeymap")
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
describe ".open(path)", ->
|
2012-06-16 02:24:49 +04:00
|
|
|
newWindow = null
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2012-06-16 02:24:49 +04:00
|
|
|
newWindow?.close()
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
describe "when opening a file", ->
|
2012-01-05 23:20:18 +04:00
|
|
|
it "displays it in a new window with the contents of the file loaded", ->
|
2012-02-29 05:24:58 +04:00
|
|
|
filePath = null
|
|
|
|
|
2012-03-01 00:04:35 +04:00
|
|
|
filePath = require.resolve 'fixtures/sample.txt'
|
2012-06-16 02:24:49 +04:00
|
|
|
previousWindowCount = atom.windows.length
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2012-03-01 00:04:35 +04:00
|
|
|
atom.open filePath
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2012-03-01 00:04:35 +04:00
|
|
|
waitsFor "window to open", ->
|
2012-06-16 02:24:49 +04:00
|
|
|
atom.windows.length > previousWindowCount
|
2012-01-04 22:51:41 +04:00
|
|
|
|
2012-03-01 00:04:35 +04:00
|
|
|
runs ->
|
2012-06-16 02:24:49 +04:00
|
|
|
expect(atom.windows.length).toBe previousWindowCount + 1
|
|
|
|
newWindow = _.last(atom.windows)
|
2012-07-04 22:27:30 +04:00
|
|
|
expect(newWindow.rootView.getActiveEditor().getBuffer().getPath()).toEqual filePath
|
|
|
|
expect(newWindow.rootView.getActiveEditor().getBuffer().getText()).toEqual fs.read(filePath)
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
describe ".windowOpened(window)", ->
|
2012-04-03 21:33:08 +04:00
|
|
|
atom = null
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
beforeEach ->
|
2012-04-03 21:33:08 +04:00
|
|
|
atom = new Atom
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
it "adds the window to the windows array if it isn't already present", ->
|
2012-04-03 21:33:08 +04:00
|
|
|
atom.windowOpened window
|
|
|
|
atom.windowOpened window
|
|
|
|
expect(atom.windows).toEqual [window]
|
2012-03-16 02:10:55 +04:00
|
|
|
|
|
|
|
|
|
|
|
|