Expose fs as an option to override the default implementations

This commit is contained in:
Patrick Malouin
2019-06-27 09:25:17 +08:00
committed by Jun Yang
parent 2ae8c37a4f
commit edb2cc1f37
4 changed files with 33 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
import { expect } from 'chai'
import Liquid from '../../../src/liquid'
describe('LiquidOptions#fs', function () {
let engine: Liquid
const fs = {
exists: () => Promise.resolve(true),
readFile: () => Promise.resolve('test file content'),
resolve: () => 'resolved'
}
beforeEach(function () {
engine = new Liquid({
root: '/root/',
fs
})
})
it('should be used to read templates', function () {
return engine.renderFile('files/foo')
.then(x => expect(x).to.equal('test file content'))
})
})