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