refactor: static strict_filters, disable settigns when rendering

This commit is contained in:
harttle
2016-11-09 02:37:52 +08:00
parent 4bdc169d0f
commit cb3378b648
7 changed files with 41 additions and 41 deletions
+8 -6
View File
@@ -5,7 +5,7 @@ const mock = require('mock-fs');
chai.use(require("chai-as-promised"));
describe('liquid', function() {
var engine, ctx;
var engine, strictEngine, ctx;
beforeEach(function() {
ctx = {
name: 'harttle',
@@ -18,6 +18,11 @@ describe('liquid', function() {
root: '/root/',
extname: '.html'
});
strictEngine = Liquid({
root: '/root',
extname: '.html',
strict_filters: true
});
mock({
'/root/files/foo.html': 'foo',
'/root/files/name.html': 'My name is {{name}}.',
@@ -40,13 +45,10 @@ describe('liquid', function() {
return engine.parseAndRender('foo{{zzz}}bar', ctx).should.eventually.equal('foobar');
});
it('should render as null when filter undefined', function() {
return engine.parseAndRender('{{arr | filter1}}', ctx).should.eventually.equal('');
return engine.parseAndRender('{{"foo" | filter1}}', ctx).should.eventually.equal('foo');
});
it('should throw upon undefined filter when strict_filters set', function() {
var opts = {
strict_filters: true
};
return expect(engine.parseAndRender('{{arr | filter1}}', ctx, opts)).to
return expect(strictEngine.parseAndRender('{{arr | filter1}}', ctx)).to
.be.rejectedWith(/undefined filter: filter1/);
});
});