Buffer is empty when created with no url.

This commit is contained in:
Corey Johnson & Nathan Sobo
2011-12-15 15:16:44 -08:00
parent 0438ecad0b
commit 5fbb320957
2 changed files with 6 additions and 1 deletions

View File

@@ -7,3 +7,7 @@ describe 'Buffer', ->
filePath = require.resolve 'fixtures/sample.txt'
buffer = new Buffer filePath
expect(buffer.getText()).toBe fs.read(filePath)
it "loads an empty buffer if no url is given", ->
buffer = new Buffer null
expect(buffer.getText()).toBe ""

View File

@@ -7,7 +7,8 @@ class Buffer
url: null
constructor: (@url) ->
@aceDocument = new Document fs.read(@url)
text = if @url then fs.read(@url) else ""
@aceDocument = new Document text
getText: ->
@aceDocument.getValue()