tumble/test/01_basics_mocha.coffee

47 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2013-03-06 17:57:12 +00:00
chai = require 'chai'
assert = chai.assert
expect = chai.expect
should = chai.should()
tumble = require('../lib/tumble')
2013-03-06 17:57:12 +00:00
test_data = [
{
'input': '',
'output': '',
'description': "no input"
}
{
'input': '<html>',
'output': '<html>',
'description': "just text"
}
{
'input': '<h1>{name}</h1>'
'output': '<h1>Elf Sternberg</h1>'
'data': {'name': 'Elf Sternberg'},
'description': "a simple substitution"
}
{
'input': '<h1>{title} {name}</h1>'
'output': '<h1>Mr. Elf Sternberg</h1>'
'data': {'name': 'Elf Sternberg', 'title': 'Mr.'},
'description': "two simple substitutions"
}
{
'input': '<ul>{block:Stories}{Title}{/block:Stories}</ul>'
'output': '<ul>AAABBB</ul>'
'data': {'stories': {'title': 'AAA'}},
'description': "a conditional block"
}]
describe "Basic Functionality", ->
for data in test_data
do (data) ->
it "should work with #{data.description}", ->
r = tumble(data.input)(data.data)
r.should.equal data.output