mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
test cases for stringify
This commit is contained in:
@@ -11,12 +11,14 @@ function isString (value) {
|
||||
}
|
||||
|
||||
function stringify (value) {
|
||||
if (!isNil(value)) {
|
||||
if (typeof value.to_liquid === 'function') {
|
||||
return stringify(value.to_liquid())
|
||||
} else if (typeof value.toLiquid === 'function') {
|
||||
return stringify(value.toLiquid())
|
||||
}
|
||||
if (isNil(value)) {
|
||||
return String(value)
|
||||
}
|
||||
if (typeof value.to_liquid === 'function') {
|
||||
return stringify(value.to_liquid())
|
||||
}
|
||||
if (typeof value.toLiquid === 'function') {
|
||||
return stringify(value.toLiquid())
|
||||
}
|
||||
if (isString(value)) {
|
||||
return value
|
||||
|
||||
@@ -44,6 +44,12 @@ describe('util/underscore', function () {
|
||||
it('should recursively call toLiquid()', function () {
|
||||
expect(_.stringify({toLiquid: () => ({toLiquid: () => 'foo'})})).to.equal('foo')
|
||||
})
|
||||
it('should return "null" for null', function () {
|
||||
expect(_.stringify(null)).to.equal('null')
|
||||
})
|
||||
it('should return "undefined" for undefined', function () {
|
||||
expect(_.stringify(undefined)).to.equal('undefined')
|
||||
})
|
||||
})
|
||||
describe('.forOwn()', function () {
|
||||
it('should iterate all properties', function () {
|
||||
|
||||
Reference in New Issue
Block a user