refactor: use camelCase for JavaScript APIs

BREAKING CHANGE: Options and method names in JavaScript API are now renamed to cammelCase, for a complete list see #109
This commit is contained in:
Jun Yang
2019-03-10 19:21:09 +08:00
parent 4a8088d4e4
commit 64e0c876e9
12 changed files with 16 additions and 68 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import Liquid from '../../../src/liquid'
import { expect } from 'chai'
describe('LiquidOptions#strict_*', function () {
describe('LiquidOptions#strict*', function () {
let engine: Liquid
const ctx = {}
beforeEach(function () {
+10 -10
View File
@@ -5,35 +5,35 @@ describe('LiquidOptions#trimming', function () {
const ctx = { name: 'harttle' }
describe('tag trimming', function () {
it('should respect trim_tag_left', async function () {
const engine = new Liquid({ trim_tag_left: true } as any)
it('should respect trimTagLeft', async function () {
const engine = new Liquid({ trimTagLeft: true })
const html = await engine.parseAndRender(' \n \t{%if true%}foo{%endif%} ')
return expect(html).to.equal('foo ')
})
it('should respect trim_tag_right', async function () {
const engine = new Liquid({ trim_tag_right: true } as any)
it('should respect trimTagRight', async function () {
const engine = new Liquid({ trimTagRight: true } as any)
const html = await engine.parseAndRender('\t{%if true%}foo{%endif%} \n')
return expect(html).to.equal('\tfoo')
})
it('should not trim value', async function () {
const engine = new Liquid({ trim_tag_left: true, trim_tag_right: true } as any)
const engine = new Liquid({ trimTagLeft: true, trimTagRight: true } as any)
const html = await engine.parseAndRender('{%if true%}a {{name}} b{%endif%}', ctx)
return expect(html).to.equal('a harttle b')
})
})
describe('value trimming', function () {
it('should respect trim_output_left', async function () {
const engine = new Liquid({ trim_output_left: true } as any)
it('should respect trimOutputLeft', async function () {
const engine = new Liquid({ trimOutputLeft: true } as any)
const html = await engine.parseAndRender(' \n \t{{name}} ', ctx)
return expect(html).to.equal('harttle ')
})
it('should respect trim_output_right', async function () {
const engine = new Liquid({ trim_output_right: true } as any)
it('should respect trimOutputRight', async function () {
const engine = new Liquid({ trimOutputRight: true } as any)
const html = await engine.parseAndRender(' \n \t{{name}} ', ctx)
return expect(html).to.equal(' \n \tharttle')
})
it('should respect not trim tag', async function () {
const engine = new Liquid({ trim_output_left: true, trim_output_right: true } as any)
const engine = new Liquid({ trimOutputLeft: true, trimOutputRight: true } as any)
const html = await engine.parseAndRender('\t{% if true %} aha {%endif%}\t')
return expect(html).to.equal('\t aha \t')
})
-9
View File
@@ -85,15 +85,6 @@ describe('scope', function () {
it("should throw when '' unbalanced", async function () {
expect(scope.get("foo['bar]")).to.be.rejectedWith(/unbalanced '/)
})
it('should respect to to_liquid', async function () {
const scope = new Scope({ foo: {
to_liquid: () => ({ bar: 'BAR' }),
bar: 'bar'
} })
expect(await scope.get('foo.bar')).to.equal('BAR')
})
it('should respect to toLiquid', async function () {
const scope = new Scope({ foo: {
toLiquid: () => ({ bar: 'BAR' }),
-14
View File
@@ -11,14 +11,6 @@ describe('Output', function () {
Filter.clear()
})
it('should respect to .to_liquid() method', async function () {
const scope = new Scope({
bar: { to_liquid: () => 'custom' }
})
const output = new Output({ value: 'bar' } as OutputToken, false)
const html = await output.render(scope)
return expect(html).to.equal('custom')
})
it('should stringify objects', async function () {
const scope = new Scope({
foo: { obj: { arr: ['a', 2] } }
@@ -39,12 +31,6 @@ describe('Output', function () {
const str = await output.render(scope)
return expect(str).to.equal('FOO')
})
it('should respect to .to_s()', async () => {
const scope = new Scope({ obj: { to_s: () => 'FOO' } })
const output = new Output({ value: 'obj' } as OutputToken, false)
const str = await output.render(scope)
return expect(str).to.equal('FOO')
})
it('should respect to .toString()', async () => {
const scope = new Scope({ obj: { toString: () => 'FOO' } })
const output = new Output({ value: 'obj' } as OutputToken, false)
-3
View File
@@ -19,9 +19,6 @@ describe('util/underscore', function () {
})
})
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')
})