mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
feature: support toLiquid, working on #81
This commit is contained in:
@@ -96,6 +96,14 @@ describe('scope', function () {
|
||||
expect(scope.get('foo.bar')).to.equal('BAR')
|
||||
})
|
||||
|
||||
it('should respect to toLiquid', function () {
|
||||
let scope = Scope.factory({foo: {
|
||||
toLiquid: () => ({bar: 'BAR'}),
|
||||
bar: 'bar'
|
||||
}})
|
||||
expect(scope.get('foo.bar')).to.equal('BAR')
|
||||
})
|
||||
|
||||
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'])
|
||||
|
||||
@@ -34,6 +34,17 @@ describe('util/underscore', function () {
|
||||
expect(_.isString(123)).to.be.false
|
||||
})
|
||||
})
|
||||
describe('.stringify()', function () {
|
||||
it('should respect to to_liquid() method', function () {
|
||||
expect(_.stringify({to_liquid: () => 'foo'})).to.equal('foo')
|
||||
})
|
||||
it('should respect to toLiquid() method', function () {
|
||||
expect(_.stringify({toLiquid: () => 'foo'})).to.equal('foo')
|
||||
})
|
||||
it('should recursively call toLiquid()', function () {
|
||||
expect(_.stringify({toLiquid: () => ({toLiquid: () => 'foo'})})).to.equal('foo')
|
||||
})
|
||||
})
|
||||
describe('.forOwn()', function () {
|
||||
it('should iterate all properties', function () {
|
||||
var spy = sinon.spy()
|
||||
|
||||
Reference in New Issue
Block a user