spectacular
Version:
Advanced BDD framework for CoffeeScript and JavaScript
55 lines (39 loc) • 1.48 kB
text/coffeescript
ErrorSourceFormatter = spectacular.formatters.console.ErrorSourceFormatter
describe ErrorSourceFormatter, ->
fixture 'errors/source_formatted.txt', as: 'expected'
fixture 'errors/source.txt', as: 'source'
context 'when the file has a source map', ->
given 'filePath', -> fixturePath 'errors/source.coffee'
given 'options', ->
source =
{
hasSourceMap: -> true
getOriginalSourceFor: (file, line, column) ->
promise = new spectacular.Promise
promise.resolve({content: source, line, column})
promise
}
given 'formatter', ->
new ErrorSourceFormatter , , '3', '11'
subject 'promise', -> .format()
itBehavesLike 'a formatter'
context 'when the file does not have a source map', ->
given 'filePath', -> fixturePath 'errors/source.js'
given 'options', ->
source =
{
hasSourceMap: -> false
getOriginalSourceFor: (file, line, column) ->
loadFile: ->
promise = new spectacular.Promise
promise.resolve(source)
promise
}
before ->
spyOn .getOriginalSourceFor
given 'formatter', ->
new ErrorSourceFormatter , , '3', '11'
subject 'promise', -> .format()
itBehavesLike 'a formatter'
the 'options.getOriginalSourceFor method', ->
.getOriginalSourceFor.shouldnt haveBeenCalled