test: coverage to 100%

This commit is contained in:
Harttle
2021-10-01 15:55:31 +08:00
committed by harttle
parent 9a96b4aba3
commit 4358c9630f
11 changed files with 115 additions and 65 deletions
+12 -1
View File
@@ -1,5 +1,7 @@
import { expect } from 'chai'
import { expect, use } from 'chai'
import { Liquid } from '../../../src/liquid'
import * as chaiAsPromised from 'chai-as-promised'
use(chaiAsPromised)
describe('LiquidOptions#fs', function () {
let engine: Liquid
@@ -31,4 +33,13 @@ describe('LiquidOptions#fs', function () {
const html = engine.renderFileSync('notexist/foo')
expect(html).to.equal('content for /root/files/fallback')
})
it('should throw lookup failure if fallback not specified', function () {
const engine = new Liquid({
root: '/root/',
fs: { ...fs, fallback: undefined }
} as any)
return expect(engine.renderFile('notexist/foo'))
.to.be.rejectedWith('Failed to lookup')
})
})
+9
View File
@@ -130,4 +130,13 @@ describe('Liquid', function () {
.to.throw(/Failed to lookup "\/not\/exist.html" in "\/boo,\/root\/"/)
})
})
describe('#enderToNodeStream', function () {
const engine = new Liquid()
it('should render a simple value', function (done) {
const stream = engine.renderToNodeStream(engine.parse('{{"foo"}}'))
let html = ''
stream.on('data', data => { html += data })
stream.on('end', () => { expect(html).to.equal('foo'); done() })
})
})
})