mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -07:00
feature: strict rendering, close #9
This commit is contained in:
@@ -42,14 +42,6 @@ describe('error', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw ParseError when filter not exist', function() {
|
||||
return test(engine.parseAndRender('{{ a | xz }}', {}), function(err){
|
||||
expect(err.name).to.equal('ParseError');
|
||||
expect(err.message).to.equal('filter "xz" not found');
|
||||
expect(err.input).to.equal('{{ a | xz }}');
|
||||
expect(err.line).to.equal(1);
|
||||
});
|
||||
});
|
||||
it('should throw ParseError when tag not exist', function() {
|
||||
return test(engine.parseAndRender('{% a %}', {}), function(err){
|
||||
expect(err.name).to.equal('ParseError');
|
||||
|
||||
+4
-4
@@ -14,10 +14,10 @@ describe('filter', function() {
|
||||
filter.clear();
|
||||
scope = Scope.factory();
|
||||
});
|
||||
it('should throw when not registered', function() {
|
||||
expect(function() {
|
||||
filter.construct('foo');
|
||||
}).to.throw(/filter "foo" not found/);
|
||||
it('should return undefined when not registered', function() {
|
||||
var result = filter.construct('foo');
|
||||
expect(result.name).to.equal('foo');
|
||||
expect(result.error).to.be.an('Error');
|
||||
});
|
||||
|
||||
it('should parse argument syntax', function(){
|
||||
|
||||
@@ -37,6 +37,16 @@ describe('liquid', function() {
|
||||
it('should output undefined to empty', 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('');
|
||||
});
|
||||
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
|
||||
.be.rejectedWith(/undefined filter: filter1/);
|
||||
});
|
||||
it('should parse html', function() {
|
||||
(function() {
|
||||
engine.parse('{{obj}}');
|
||||
|
||||
Reference in New Issue
Block a user