mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
refactor: strictly typed
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import * as chai from 'chai'
|
||||
import * as sinon from 'sinon'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import Filter from 'src/template/filter'
|
||||
import Filter from 'src/template/filter/filter'
|
||||
import Scope from 'src/scope/scope'
|
||||
|
||||
chai.use(sinonChai)
|
||||
const expect = chai.expect
|
||||
|
||||
describe('filter', function () {
|
||||
let scope
|
||||
let scope: Scope
|
||||
beforeEach(function () {
|
||||
Filter.clear()
|
||||
scope = new Scope()
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as chai from 'chai'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Output from 'src/template/output'
|
||||
import OutputToken from 'src/parser/output-token'
|
||||
import Filter from 'src/template/filter'
|
||||
import Filter from 'src/template/filter/filter'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('Output', function () {
|
||||
return expect(html).equal('{"num":2,"circular":{"bar":"bar"}}')
|
||||
})
|
||||
it('should skip function property', async function () {
|
||||
const scope = new Scope({ obj: { foo: 'foo', bar: x => x } })
|
||||
const scope = new Scope({ obj: { foo: 'foo', bar: (x: any) => x } })
|
||||
const output = new Output({ value: 'obj' } as OutputToken)
|
||||
const html = await output.render(scope)
|
||||
return expect(html).to.equal('{"foo":"foo"}')
|
||||
@@ -53,7 +53,7 @@ describe('Output', function () {
|
||||
return expect(str).to.equal('FOO')
|
||||
})
|
||||
it('should respect to .liquid_method_missing()', async () => {
|
||||
const scope = new Scope({ obj: { liquid_method_missing: x => x.toUpperCase() } })
|
||||
const scope = new Scope({ obj: { liquid_method_missing: (x: string) => x.toUpperCase() } })
|
||||
const output = new Output({ value: 'obj.foo' } as OutputToken)
|
||||
const str = await output.render(scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
|
||||
@@ -11,7 +11,7 @@ const expect = chai.expect
|
||||
const liquid = new Liquid()
|
||||
|
||||
describe('tag', function () {
|
||||
let scope
|
||||
let scope: Scope
|
||||
before(function () {
|
||||
scope = new Scope({
|
||||
foo: 'bar',
|
||||
@@ -56,7 +56,7 @@ describe('tag', function () {
|
||||
})
|
||||
|
||||
describe('hash', function () {
|
||||
let spy, token
|
||||
let spy: sinon.SinonSpy, token: TagToken
|
||||
beforeEach(function () {
|
||||
spy = sinon.spy()
|
||||
Tag.register('foo', {
|
||||
@@ -67,7 +67,7 @@ describe('tag', function () {
|
||||
value: 'foo aa:foo bb: arr[0] cc: 2.3\ndd:bar.coo',
|
||||
name: 'foo',
|
||||
args: 'aa:foo bb: arr[0] cc: 2.3\ndd:bar.coo'
|
||||
}
|
||||
} as TagToken
|
||||
})
|
||||
it('should call tag.render with scope', async function () {
|
||||
await new Tag(token, [], liquid).render(scope)
|
||||
|
||||
@@ -2,13 +2,13 @@ import * as chai from 'chai'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import * as sinon from 'sinon'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Filter from 'src/template/filter'
|
||||
import Filter from 'src/template/filter/filter'
|
||||
import Value from 'src/template/value'
|
||||
|
||||
chai.use(sinonChai)
|
||||
|
||||
const expect = chai.expect
|
||||
const add = (l, r) => l + r
|
||||
const add = (l: number, r: number) => l + r
|
||||
|
||||
describe('Value', function () {
|
||||
beforeEach(() => Filter.clear())
|
||||
|
||||
Reference in New Issue
Block a user