pulsar/spec/app/atom-spec.coffee

46 lines
1.2 KiB
CoffeeScript
Raw Normal View History

Atom = require 'atom'
fs = require 'fs'
_ = require 'underscore'
2011-12-13 04:24:55 +04:00
describe "Atom", ->
beforeEach ->
spyOn(Atom.prototype, "setUpKeymap")
describe ".open(path)", ->
newWindow = null
afterEach ->
newWindow?.close()
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", ->
filePath = null
filePath = require.resolve 'fixtures/sample.txt'
previousWindowCount = atom.windows.length
2011-12-13 04:24:55 +04:00
atom.open filePath
2011-12-13 04:24:55 +04:00
waitsFor "window to open", ->
atom.windows.length > previousWindowCount
2012-01-04 22:51:41 +04:00
runs ->
expect(atom.windows.length).toBe previousWindowCount + 1
newWindow = _.last(atom.windows)
expect(newWindow.rootView.getActiveEditor().getBuffer().getPath()).toEqual filePath
expect(newWindow.rootView.getActiveEditor().getBuffer().getText()).toEqual fs.read(filePath)
describe ".windowOpened(window)", ->
atom = null
beforeEach ->
atom = new Atom
it "adds the window to the windows array if it isn't already present", ->
atom.windowOpened window
atom.windowOpened window
expect(atom.windows).toEqual [window]