Buffer with no url returns Text as its mode.

This commit is contained in:
Corey Johnson
2011-12-19 16:40:55 -08:00
parent a72fb416f8
commit 1abccbf9eb
2 changed files with 6 additions and 3 deletions

View File

@@ -51,7 +51,10 @@ describe 'Buffer', ->
buffer = new Buffer 'something.js'
expect(buffer.getMode().name).toBe 'javascript'
describe "when no url is given", ->
it "sets 'mode' to text mode", ->
buffer = new Buffer 'something'
expect(buffer.getMode().name).toBe 'text'
describe "when no url is given", ->
it "sets 'mode' to text mode", ->
buffer = new Buffer null
expect(buffer.getMode().name).toBe 'text'

View File

@@ -23,7 +23,7 @@ class Buffer
getMode: ->
return @mode if @mode
extension = @url.split('/').pop().split('.').pop()
extension = if @url then @url.split('/').pop().split('.').pop() else null
modeName = switch extension
when "js" then "javascript"
else "text"