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