mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
test: coverage to 100%
This commit is contained in:
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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() })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user