mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: static strict_filters, disable settigns when rendering
This commit is contained in:
+8
-6
@@ -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/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user