mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
feat: exported Drop interface for #107
Deprecate snake_cased options and APIs, sed #109
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { expect } from 'chai'
|
||||
import { Drop } from '../../../src/drop/drop'
|
||||
|
||||
describe('drop/drop', function () {
|
||||
class CustomDrop extends Drop { }
|
||||
|
||||
it('.valueOf() should return undefined by default', async function () {
|
||||
expect(new CustomDrop().valueOf()).to.be.undefined
|
||||
})
|
||||
})
|
||||
@@ -181,11 +181,11 @@ describe('scope', function () {
|
||||
expect(scope.get('foo')).to.equal('bar')
|
||||
})
|
||||
})
|
||||
describe('strict_variables', function () {
|
||||
describe('strictVariables', function () {
|
||||
let scope: Scope
|
||||
beforeEach(function () {
|
||||
scope = new Scope(ctx, {
|
||||
strict_variables: true
|
||||
strictVariables: true
|
||||
} as any)
|
||||
})
|
||||
it('should throw when variable not defined', function () {
|
||||
|
||||
@@ -25,20 +25,13 @@ describe('Output', function () {
|
||||
})
|
||||
const output = new Output({ value: 'foo' } as OutputToken, false)
|
||||
const html = await output.render(scope)
|
||||
return expect(html).to.equal('{"obj":{"arr":["a",2]}}')
|
||||
})
|
||||
it('should skip circular property', async function () {
|
||||
const ctx = { foo: { num: 2 }, bar: 'bar' } as any
|
||||
ctx.foo.circular = ctx
|
||||
const output = new Output({ value: 'foo' } as OutputToken, false)
|
||||
const html = await output.render(new Scope(ctx))
|
||||
return expect(html).equal('{"num":2,"circular":{"bar":"bar"}}')
|
||||
return expect(html).to.equal('[object Object]')
|
||||
})
|
||||
it('should skip function property', async function () {
|
||||
const scope = new Scope({ obj: { foo: 'foo', bar: (x: any) => x } })
|
||||
const output = new Output({ value: 'obj' } as OutputToken, false)
|
||||
const html = await output.render(scope)
|
||||
return expect(html).to.equal('{"foo":"foo"}')
|
||||
return expect(html).to.equal('[object Object]')
|
||||
})
|
||||
it('should respect to .toString()', async () => {
|
||||
const scope = new Scope({ obj: { toString: () => 'FOO' } })
|
||||
@@ -52,9 +45,9 @@ describe('Output', function () {
|
||||
const str = await output.render(scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
})
|
||||
it('should respect to .liquid_method_missing()', async () => {
|
||||
const scope = new Scope({ obj: { liquid_method_missing: (x: string) => x.toUpperCase() } })
|
||||
const output = new Output({ value: 'obj.foo' } as OutputToken, false)
|
||||
it('should respect to .toString()', async () => {
|
||||
const scope = new Scope({ obj: { toString: () => 'FOO' } })
|
||||
const output = new Output({ value: 'obj' } as OutputToken, false)
|
||||
const str = await output.render(scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
})
|
||||
|
||||
@@ -34,10 +34,6 @@ describe('util/underscore', function () {
|
||||
it('should return "" for undefined', function () {
|
||||
expect(_.stringify(undefined)).to.equal('')
|
||||
})
|
||||
it('should use Object.prototype.toString if no toString method exists', function () {
|
||||
const obj = { toString: undefined }
|
||||
expect(_.stringify(obj)).to.equal('[object Object]')
|
||||
})
|
||||
it('should return regex string for RegExp', function () {
|
||||
const reg = /foo/g
|
||||
expect(_.stringify(reg)).to.equal('/foo/g')
|
||||
|
||||
Reference in New Issue
Block a user