Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
convert filter test to mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Oct 27, 2012
1 parent f39a4b2 commit e16e78f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
3 changes: 1 addition & 2 deletions lib/tags/extends.test.js
@@ -1,5 +1,4 @@
var testCase = require('nodeunit').testCase,
swig = require('../../index');
var swig = require('../../index');

describe('Tag: extends', function () {

Expand Down
32 changes: 13 additions & 19 deletions lib/tags/filter.test.js
@@ -1,27 +1,21 @@
var testCase = require('nodeunit').testCase,
swig = require('../../index');
var swig = require('../../index');

exports.filter = testCase({
setUp: function (callback) {
describe('Tag: filter', function () {
beforeEach(function () {
swig.init({});
callback();
},
});

basic: function (test) {
var tpl = swig.compile('{% filter capitalize %}oh HEY there{% endfilter %}');
test.strictEqual(tpl({}), 'Oh hey there');
test.done();
},
it('accepts a filter as an argument', function () {
swig.compile('{% filter capitalize %}oh HEY there{% endfilter %}')({}).should.equal('Oh hey there');
});

'complex content': function (test) {
it('works across complex content', function () {
var tpl = swig.compile('{% filter capitalize %}oh {{ foo }} {% if here %}here{% else %}there{% endif %}{% endfilter %}');
test.strictEqual(tpl({ foo: 'HEY', here: true }), 'Oh hey here');
test.done();
},
tpl({ foo: 'HEY', here: true }).should.equal('Oh hey here');
});

args: function (test) {
it('can accept arguments for the filter', function () {
var tpl = swig.compile('{% filter replace "\\." "!" "g" %}hi. my name is paul.{% endfilter %}');
test.strictEqual(tpl({}), 'hi! my name is paul!');
test.done();
}
tpl({}).should.equal('hi! my name is paul!');
});
});

0 comments on commit e16e78f

Please sign in to comment.