chore(TypeScript): ship Liquid to class

BREAKING CHANGE: calling `Liquid()` without `new` now becomes invalid
This commit is contained in:
harttle
2019-02-14 23:53:40 +08:00
parent a626de632c
commit 1cc7249a71
27 changed files with 124 additions and 126 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ describe('engine#express()', function () {
beforeEach(function () {
app = express()
engine = Liquid({
engine = new Liquid({
root: '/root',
extname: '.html'
})
+2 -2
View File
@@ -7,8 +7,8 @@ chai.use(require('chai-as-promised'))
describe('.parseAndRender()', function () {
var engine, strictEngine
beforeEach(function () {
engine = Liquid()
strictEngine = Liquid({
engine = new Liquid()
strictEngine = new Liquid({
strict_filters: true
})
})
+5 -5
View File
@@ -8,7 +8,7 @@ chai.use(require('chai-as-promised'))
describe('#renderFile()', function () {
var engine
beforeEach(function () {
engine = Liquid({
engine = new Liquid({
root: '/root/',
extname: '.html'
})
@@ -29,7 +29,7 @@ describe('#renderFile()', function () {
.to.eventually.equal('foo')
})
it('should find files without extname', function () {
var engine = Liquid({ root: '/root' })
var engine = new Liquid({ root: '/root' })
return expect(engine.renderFile('/root/files/bar', {}))
.to.eventually.equal('bar')
})
@@ -38,7 +38,7 @@ describe('#renderFile()', function () {
.to.eventually.equal('foo')
})
it('should resolve array as root', function () {
engine = Liquid({
engine = new Liquid({
root: ['/boo', '/root/'],
extname: '.html'
})
@@ -50,7 +50,7 @@ describe('#renderFile()', function () {
files[process.cwd() + '/foo.html'] = 'FOO'
mock(files)
engine = Liquid({
engine = new Liquid({
extname: '.html'
})
return expect(engine.renderFile('foo.html'))
@@ -64,7 +64,7 @@ describe('#renderFile()', function () {
return expect(engine.renderFile('files/name', { name: 'harttle' })).to.eventually.equal('My name is harttle.')
})
it('should throw with lookup list when file not exist', function () {
engine = Liquid({
engine = new Liquid({
root: ['/boo', '/root/'],
extname: '.html'
})
+7 -7
View File
@@ -23,7 +23,7 @@ describe('xhr', () => {
})
global.XMLHttpRequest = sinon.useFakeXMLHttpRequest()
global.document = dom.window.document
engine = Liquid({
engine = new Liquid({
root: 'https://example.com/views/',
extname: '.html'
})
@@ -78,7 +78,7 @@ describe('xhr', () => {
})
describe('#renderFile() with root specified', () => {
it('should support undefined root', () => {
engine = Liquid({
engine = new Liquid({
extname: '.html'
})
server.respondWith('GET', 'https://example.com/foo/hello.html',
@@ -87,7 +87,7 @@ describe('xhr', () => {
.to.eventually.equal('hello alice5')
})
it('should support empty root', () => {
engine = Liquid({
engine = new Liquid({
root: '',
extname: '.html'
})
@@ -97,7 +97,7 @@ describe('xhr', () => {
.to.eventually.equal('hello alice5')
})
it('should support with relative path', () => {
engine = Liquid({
engine = new Liquid({
root: './views/',
extname: '.html'
})
@@ -107,7 +107,7 @@ describe('xhr', () => {
.to.eventually.equal('hello alice5')
})
it('should support with absolute path', () => {
engine = Liquid({
engine = new Liquid({
root: '/views/',
extname: '.html'
})
@@ -117,7 +117,7 @@ describe('xhr', () => {
.to.eventually.equal('hello alice5')
})
it('should support with url', () => {
engine = Liquid({
engine = new Liquid({
root: 'https://foo.com/bar/',
extname: '.html'
})
@@ -141,7 +141,7 @@ describe('xhr', () => {
.then(html => expect(html).to.equal('foo2'))
})
it('should respect cache=true option', () => {
engine = Liquid({
engine = new Liquid({
root: '/views/',
extname: '.html',
cache: true