mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix: find variable in parent scope (strict_variables)
This commit is contained in:
+28
-15
@@ -71,21 +71,6 @@ describe('scope', function() {
|
||||
}).to.throw(/unbalanced '/);
|
||||
});
|
||||
|
||||
it('should throw undefined in strict mode', function() {
|
||||
scope = Scope.factory(ctx, {
|
||||
strict_variables: true
|
||||
});
|
||||
|
||||
function fn() {
|
||||
scope.get('notdefined');
|
||||
}
|
||||
expect(fn).to.throw(/undefined variable: notdefined/);
|
||||
});
|
||||
|
||||
it('should get all properties when arguments empty', function() {
|
||||
expect(scope.getAll()).deep.equal(ctx);
|
||||
});
|
||||
|
||||
it('should access child property via dot syntax', function() {
|
||||
expect(scope.get('bar.zoo')).to.equal('coo');
|
||||
expect(scope.get('bar.arr')).to.deep.equal(['a', 'b']);
|
||||
@@ -116,6 +101,34 @@ describe('scope', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('strict_variables', function() {
|
||||
var scope;
|
||||
beforeEach(function(){
|
||||
scope = Scope.factory(ctx, {
|
||||
strict_variables: true
|
||||
});
|
||||
});
|
||||
it('should throw undefined in strict mode', function() {
|
||||
function fn() {
|
||||
scope.get('notdefined');
|
||||
}
|
||||
expect(fn).to.throw(/undefined variable: notdefined/);
|
||||
});
|
||||
it('should find variable in parent scope', function() {
|
||||
scope.set('foo', 'foo');
|
||||
scope.push({
|
||||
'bar': 'bar'
|
||||
});
|
||||
expect(scope.get('foo')).to.equal('foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getAll()', function() {
|
||||
it('should get all properties when arguments empty', function() {
|
||||
expect(scope.getAll()).deep.equal(ctx);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.push()', function() {
|
||||
it('should throw when trying to push non-object', function() {
|
||||
expect(function() {
|
||||
|
||||
Reference in New Issue
Block a user