mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
chore(typescript): ship to TypeScript
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import chai from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import Filter from '../../src/filter.js'
|
||||
import { factory as scopeFactory } from '../../src/scope.js'
|
||||
import * as chai from 'chai'
|
||||
import * as sinon from 'sinon'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import Filter from '../../src/filter'
|
||||
import { factory as scopeFactory } from '../../src/scope'
|
||||
|
||||
chai.use(sinonChai)
|
||||
const expect = chai.expect
|
||||
@@ -1,5 +1,5 @@
|
||||
import chai from 'chai'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import * as chai from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import Liquid from '../../src/index'
|
||||
|
||||
chai.use(chaiAsPromised)
|
||||
@@ -130,7 +130,7 @@ describe('filters', function () {
|
||||
return test('{{ "Tetsuro Takara" | escape }}', 'Tetsuro Takara')
|
||||
})
|
||||
it('should escape function', function () {
|
||||
return test('{{ func | escape }}', 'function func() {}')
|
||||
return test('{{ func | escape }}', 'function () { }')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import Liquid from '../../src/index.js'
|
||||
import mock from 'mock-fs'
|
||||
import chai from 'chai'
|
||||
import Liquid from '../../src/index'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chai from 'chai'
|
||||
import mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
import * as mock from 'mock-fs'
|
||||
import Liquid from '../../../src'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
import Liquid from '../../../src'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import chai from 'chai'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import Filter from '../../src/filter.js'
|
||||
import Tag from '../../src/tag.js'
|
||||
import Template from '../../src/parser.js'
|
||||
import * as chai from 'chai'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import Filter from '../../src/filter'
|
||||
import Tag from '../../src/tag'
|
||||
import Template from '../../src/parser'
|
||||
|
||||
const expect = chai.expect
|
||||
const filter = Filter()
|
||||
|
||||
+19
-19
@@ -1,12 +1,12 @@
|
||||
import chai from 'chai'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import sinon from 'sinon'
|
||||
import Tag from '../../src/tag.js'
|
||||
import { factory as scopeFactory } from '../../src/scope.js'
|
||||
import * as chai from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import * as sinon from 'sinon'
|
||||
import Tag from '../../src/tag'
|
||||
import Scope from '../../src/scope'
|
||||
import Filter from '../../src/filter'
|
||||
import Render from '../../src/render.js'
|
||||
import parser from '../../src/parser.js'
|
||||
import Render from '../../src/render'
|
||||
import parser from '../../src/parser'
|
||||
|
||||
chai.use(sinonChai)
|
||||
chai.use(chaiAsPromised)
|
||||
@@ -30,21 +30,21 @@ describe('render', function () {
|
||||
})
|
||||
|
||||
it('should render html', function () {
|
||||
const scope = scopeFactory({})
|
||||
const scope = new Scope()
|
||||
return expect(render.renderTemplates([{ type: 'html', value: '<p>' }], scope)).to.eventually.equal('<p>')
|
||||
})
|
||||
})
|
||||
|
||||
describe('.renderValue()', function () {
|
||||
it('should respect to .to_liquid() method', function () {
|
||||
const scope = scopeFactory({
|
||||
const scope = new Scope({
|
||||
bar: { to_liquid: x => 'custom' }
|
||||
})
|
||||
const tpl = Template.parseValue('bar')
|
||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('custom')
|
||||
})
|
||||
it('should stringify objects', function () {
|
||||
const scope = scopeFactory({
|
||||
const scope = new Scope({
|
||||
foo: { obj: { arr: ['a', 2] } }
|
||||
})
|
||||
const tpl = Template.parseValue('foo')
|
||||
@@ -54,29 +54,29 @@ describe('render', function () {
|
||||
const ctx = { foo: { num: 2 }, bar: 'bar' }
|
||||
ctx.foo.circular = ctx
|
||||
|
||||
const scope = scopeFactory(ctx)
|
||||
const scope = new Scope(ctx)
|
||||
const tpl = Template.parseValue('foo')
|
||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"num":2,"circular":{"bar":"bar"}}')
|
||||
})
|
||||
it('should skip function property', function () {
|
||||
const scope = scopeFactory({ obj: { foo: 'foo', bar: x => x } })
|
||||
const scope = new Scope({ obj: { foo: 'foo', bar: x => x } })
|
||||
const tpl = Template.parseValue('obj')
|
||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"foo":"foo"}')
|
||||
})
|
||||
it('should respect to .toString()', async () => {
|
||||
const scope = scopeFactory({ obj: { toString: () => 'FOO' } })
|
||||
const scope = new Scope({ obj: { toString: () => 'FOO' } })
|
||||
const tpl = Template.parseValue('obj')
|
||||
const str = await render.renderValue(tpl, scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
})
|
||||
it('should respect to .to_s()', async () => {
|
||||
const scope = scopeFactory({ obj: { to_s: () => 'FOO' } })
|
||||
const scope = new Scope({ obj: { to_s: () => 'FOO' } })
|
||||
const tpl = Template.parseValue('obj')
|
||||
const str = await render.renderValue(tpl, scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
})
|
||||
it('should respect to .liquid_method_missing()', async () => {
|
||||
const scope = scopeFactory({ obj: { liquid_method_missing: x => x.toUpperCase() } })
|
||||
const scope = new Scope({ obj: { liquid_method_missing: x => x.toUpperCase() } })
|
||||
const tpl = Template.parseValue('obj.foo')
|
||||
const str = await render.renderValue(tpl, scope)
|
||||
return expect(str).to.equal('FOO')
|
||||
@@ -93,7 +93,7 @@ describe('render', function () {
|
||||
filter.register('date', (l, r) => l + r)
|
||||
filter.register('time', (l, r) => l + 3 * r)
|
||||
const tpl = Template.parseValue('foo.bar[0] | date: "b" | time:2')
|
||||
const scope = scopeFactory({
|
||||
const scope = new Scope({
|
||||
foo: { bar: ['a'] }
|
||||
})
|
||||
expect(render.evalValue(tpl, scope)).to.equal('ab6')
|
||||
@@ -101,7 +101,7 @@ describe('render', function () {
|
||||
it('should reserve type', function () {
|
||||
filter.register('arr', () => [1])
|
||||
const tpl = Template.parseValue('"x" | arr')
|
||||
expect(render.evalValue(tpl, scopeFactory())).to.deep.equal([1])
|
||||
expect(render.evalValue(tpl, new Scope())).to.deep.equal([1])
|
||||
})
|
||||
it('should eval filter with correct arguments', function () {
|
||||
const date = sinon.stub().returns('y')
|
||||
@@ -109,7 +109,7 @@ describe('render', function () {
|
||||
filter.register('date', date)
|
||||
filter.register('time', time)
|
||||
const tpl = Template.parseValue('foo.bar | date: "b" | time:2')
|
||||
const scope = scopeFactory({
|
||||
const scope = new Scope({
|
||||
foo: { bar: 'bar' }
|
||||
})
|
||||
render.evalValue(tpl, scope)
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
import chai from 'chai'
|
||||
import { factory as scopeFactory } from '../../src/scope.js'
|
||||
import * as chai from 'chai'
|
||||
import Scope from '../../src/scope'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('scope', function () {
|
||||
arr: ['a', 'b']
|
||||
}
|
||||
}
|
||||
scope = scopeFactory(ctx)
|
||||
scope = new Scope(ctx)
|
||||
})
|
||||
|
||||
describe('#propertyAccessSeq()', function () {
|
||||
@@ -97,7 +97,7 @@ describe('scope', function () {
|
||||
})
|
||||
|
||||
it('should respect to to_liquid', function () {
|
||||
const scope = scopeFactory({ foo: {
|
||||
const scope = new Scope({ foo: {
|
||||
to_liquid: () => ({ bar: 'BAR' }),
|
||||
bar: 'bar'
|
||||
} })
|
||||
@@ -105,7 +105,7 @@ describe('scope', function () {
|
||||
})
|
||||
|
||||
it('should respect to toLiquid', function () {
|
||||
const scope = scopeFactory({ foo: {
|
||||
const scope = new Scope({ foo: {
|
||||
toLiquid: () => ({ bar: 'BAR' }),
|
||||
bar: 'bar'
|
||||
} })
|
||||
@@ -171,7 +171,7 @@ describe('scope', function () {
|
||||
describe('strict_variables', function () {
|
||||
let scope
|
||||
beforeEach(function () {
|
||||
scope = scopeFactory(ctx, {
|
||||
scope = new Scope(ctx, {
|
||||
strict_variables: true
|
||||
})
|
||||
})
|
||||
|
||||
+4
-9
@@ -1,17 +1,12 @@
|
||||
const chai = require('chai')
|
||||
const expect = chai.expect
|
||||
const syntax = require('../../src/syntax.js')
|
||||
const Scope = require('../../src/scope.js')
|
||||
|
||||
const evalExp = syntax.evalExp
|
||||
const evalValue = syntax.evalValue
|
||||
const isTruthy = syntax.isTruthy
|
||||
import Scope from '../../src/scope'
|
||||
import { expect } from 'chai'
|
||||
import { evalExp, evalValue, isTruthy } from '../../src/syntax'
|
||||
|
||||
describe('expression', function () {
|
||||
let scope
|
||||
|
||||
beforeEach(function () {
|
||||
scope = Scope.factory({
|
||||
scope = new Scope({
|
||||
one: 1,
|
||||
two: 2,
|
||||
empty: '',
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
import chai from 'chai'
|
||||
import Tag from '../../src/tag.js'
|
||||
import { factory as scopeFactory } from '../../src/scope.js'
|
||||
import sinon from 'sinon'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import * as chai from 'chai'
|
||||
import Tag from '../../src/tag'
|
||||
import Scope from '../../src/scope'
|
||||
import * as sinon from 'sinon'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
|
||||
chai.use(sinonChai)
|
||||
const expect = chai.expect
|
||||
@@ -11,7 +11,7 @@ const tag = Tag()
|
||||
describe('tag', function () {
|
||||
let scope
|
||||
before(function () {
|
||||
scope = scopeFactory({
|
||||
scope = new Scope({
|
||||
foo: 'bar',
|
||||
arr: [2, 1],
|
||||
bar: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import sinonChai from 'chai-as-promised'
|
||||
import * as chai from 'chai'
|
||||
import * as sinonChai from 'chai-as-promised'
|
||||
|
||||
chai.use(sinonChai)
|
||||
const expect = chai.expect
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src/index'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src/index'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Liquid from '../../../src'
|
||||
import mock from 'mock-fs'
|
||||
import chai from 'chai'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Liquid from '../../../src'
|
||||
import mock from 'mock-fs'
|
||||
import chai from 'chai'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Liquid from '../../../src'
|
||||
import chai from 'chai'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { resolve } from '../../src/template-browser.js'
|
||||
import chai from 'chai'
|
||||
import { resolve } from '../../src/template-browser'
|
||||
import * as chai from 'chai'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { resolve } from '../../src/template.js'
|
||||
import mock from 'mock-fs'
|
||||
import chai from 'chai'
|
||||
import path from 'path'
|
||||
import chaiAsPromised from 'chai-as-promised'
|
||||
import { resolve } from '../../src/template'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
import * as path from 'path'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import chai from 'chai'
|
||||
import assert from '../../../src/util/assert.js'
|
||||
import * as chai from 'chai'
|
||||
import assert from '../../../src/util/assert'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Liquid from '../../../src'
|
||||
import mock from 'mock-fs'
|
||||
import chai from 'chai'
|
||||
import path from 'path'
|
||||
import * as mock from 'mock-fs'
|
||||
import * as chai from 'chai'
|
||||
import * as path from 'path'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import chai from 'chai'
|
||||
import t from '../../../src/util/strftime.js'
|
||||
import * as chai from 'chai'
|
||||
import t from '../../../src/util/strftime'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import chai from 'chai'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import sinon from 'sinon'
|
||||
import { RenderError, RenderBreakError } from '../../../src/util/error.js'
|
||||
import * as _ from '../../../src/util/underscore.js'
|
||||
import * as chai from 'chai'
|
||||
import * as sinonChai from 'sinon-chai'
|
||||
import * as sinon from 'sinon'
|
||||
import { RenderError, RenderBreakError } from '../../../src/util/error'
|
||||
import * as _ from '../../../src/util/underscore'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(sinonChai)
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { read } from '../../src/template-browser.js'
|
||||
import sinon from 'sinon'
|
||||
import chai from 'chai'
|
||||
import { read } from '../../src/template-browser'
|
||||
import * as sinon from 'sinon'
|
||||
import * as chai from 'chai'
|
||||
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user