Merge branch 'master' of github.com:github/atom

This commit is contained in:
Nathan Sobo
2012-06-12 16:15:23 -06:00
3 changed files with 15 additions and 15 deletions

View File

@@ -81,11 +81,11 @@ describe 'Buffer', ->
expect(buffer).toBe savedBuffer
describe 'when the state has text (and no path)', ->
it 'creates a new buffer with the given text', ->
it 'creates a new empty buffer (does not serialze unsaved text)', ->
unsavedBuffer = project.open()
unsavedBuffer.setText("OMGWTFBBQ")
buffer = Buffer.deserialize(unsavedBuffer.serialize(), project)
expect(buffer).toBe unsavedBuffer
expect(buffer.getText()).toBe ""
describe ".getLines()", ->
it "returns an array of lines in the text contents", ->

View File

@@ -25,6 +25,16 @@ describe "fs", ->
expect(fs.directory(require.resolve('fixtures/dir'))).toBe require.resolve('fixtures')
expect(fs.directory(require.resolve('fixtures/dir/'))).toBe require.resolve('fixtures')
describe ".exists(path)", ->
it "returns true when path exsits", ->
expect(fs.exists(require.resolve('fixtures'))).toBe true
it "returns false when path doesn't exsit", ->
expect(fs.exists(require.resolve("fixtures") + "/-nope-does-not-exist")).toBe false
expect(fs.exists("")).toBe false
expect(fs.exists(null)).toBe false
expect(fs.exists(undefined)).toBe false
describe ".join(paths...)", ->
it "concatenates the given paths with the directory seperator", ->
expect(fs.join('a')).toBe 'a'

View File

@@ -13,20 +13,13 @@ class Buffer
path: null
@deserialize: (state, project) ->
if state.path
buffer = project.open(state.path)
else
buffer = project.bufferWithId(state.id) ? project.open()
buffer.setText(state.text)
buffer.modified = state.modified
buffer
project.open(state.path)
constructor: (path) ->
@id = @constructor.idCounter++
@setPath(path)
@lines = ['']
if @getPath() and fs.exists(@getPath())
if fs.exists(@getPath())
@setText(fs.read(@getPath()))
else
@setText('')
@@ -34,10 +27,7 @@ class Buffer
@modified = false
serialize: ->
if @getPath()
{ path: @path }
else
{ text: @getText(), id: @id , modified: @modified}
path: @getPath()
getPath: ->
@path