2011-12-15 04:24:30 +04:00
|
|
|
App = require 'app'
|
2011-12-16 02:13:34 +04:00
|
|
|
fs = require 'fs'
|
2011-12-13 04:24:55 +04:00
|
|
|
|
|
|
|
describe "App", ->
|
2011-12-15 04:24:30 +04:00
|
|
|
app = null
|
2011-12-13 04:24:55 +04:00
|
|
|
|
|
|
|
beforeEach ->
|
2011-12-15 04:24:30 +04:00
|
|
|
app = new App()
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2011-12-15 04:24:30 +04:00
|
|
|
afterEach ->
|
2011-12-15 06:30:17 +04:00
|
|
|
window.close() for window in app.windows()
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2011-12-15 04:24:30 +04:00
|
|
|
describe "open", ->
|
2012-01-04 22:51:41 +04:00
|
|
|
describe "when opening a filePath", ->
|
|
|
|
it "loads a buffer with filePath contents and displays it in a new window", ->
|
|
|
|
filePath = require.resolve 'fixtures/sample.txt'
|
|
|
|
expect(app.windows().length).toBe 0
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2012-01-04 22:51:41 +04:00
|
|
|
app.open filePath
|
2011-12-13 04:24:55 +04:00
|
|
|
|
2012-01-04 22:51:41 +04:00
|
|
|
expect(app.windows().length).toBe 1
|
|
|
|
newWindow = app.windows()[0]
|
2011-12-16 02:13:34 +04:00
|
|
|
|
2012-01-04 22:51:41 +04:00
|
|
|
expect(newWindow.rootView.editor.buffer.url).toEqual filePath
|
|
|
|
expect(newWindow.rootView.editor.buffer.getText()).toEqual fs.read(filePath)
|
|
|
|
|
|
|
|
describe "when opening a dirPath", ->
|
|
|
|
it "loads an empty buffer", ->
|
|
|
|
dirPath = require.resolve 'fixtures'
|
|
|
|
expect(app.windows().length).toBe 0
|
|
|
|
|
|
|
|
app.open dirPath
|
|
|
|
|
|
|
|
expect(app.windows().length).toBe 1
|
|
|
|
newWindow = app.windows()[0]
|
|
|
|
|
|
|
|
expect(newWindow.rootView.editor.buffer.url).toBeUndefined
|
|
|
|
expect(newWindow.rootView.editor.buffer.getText()).toBe ""
|