mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: switch Context <-> Scope concepts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as chai from 'chai'
|
||||
import Scope from '../../../src/scope/scope'
|
||||
import Context from '../../../src/context/context'
|
||||
import Output from '../../../src/template/output'
|
||||
import OutputToken from '../../../src/parser/output-token'
|
||||
import { Filter } from '../../../src/template/filter/filter'
|
||||
@@ -12,7 +12,7 @@ describe('Output', function () {
|
||||
})
|
||||
|
||||
it('should stringify objects', async function () {
|
||||
const scope = new Scope({
|
||||
const scope = new Context({
|
||||
foo: { obj: { arr: ['a', 2] } }
|
||||
})
|
||||
const output = new Output({ value: 'foo' } as OutputToken, false)
|
||||
@@ -20,19 +20,19 @@ describe('Output', function () {
|
||||
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 scope = new Context({ 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('[object Object]')
|
||||
})
|
||||
it('should respect to .toString()', async () => {
|
||||
const scope = new Scope({ obj: { toString: () => 'FOO' } })
|
||||
const scope = new Context({ obj: { toString: () => '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 scope = new Context({ obj: { toString: () => 'FOO' } })
|
||||
const output = new Output({ value: 'obj' } as OutputToken, false)
|
||||
const str = await output.render(scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
|
||||
Reference in New Issue
Block a user