mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
test: cases for parse(<tpl>, <relative filepath>), #395
This commit is contained in:
@@ -113,6 +113,30 @@ describe('Liquid', function () {
|
||||
expect(str).to.equal('foo')
|
||||
})
|
||||
})
|
||||
describe('#parse', function () {
|
||||
it('should resolve relative partials', function () {
|
||||
const engine = new Liquid({
|
||||
root: ['/'],
|
||||
extname: '.html'
|
||||
})
|
||||
mock({
|
||||
'/root/partial.html': 'foo'
|
||||
})
|
||||
const tpls = engine.parse('{% render "./partial.html" %}', '/root/index.html')
|
||||
return expect(engine.renderSync(tpls)).to.equal('foo')
|
||||
})
|
||||
it('should resolve against pwd for relative filepath', function () {
|
||||
const engine = new Liquid({
|
||||
root: ['/'],
|
||||
extname: '.html'
|
||||
})
|
||||
mock({
|
||||
[`${process.cwd()}/partial.html`]: 'foo'
|
||||
})
|
||||
const tpls = engine.parse('{% render "./partial.html" %}', './index.html')
|
||||
return expect(engine.renderSync(tpls)).to.equal('foo')
|
||||
})
|
||||
})
|
||||
describe('#parseFileSync', function () {
|
||||
it('should throw with lookup list when file not exist', function () {
|
||||
const engine = new Liquid({
|
||||
|
||||
@@ -7,10 +7,10 @@ use(chaiAsPromised)
|
||||
|
||||
describe('fs/loader', function () {
|
||||
describe('.candidates()', function () {
|
||||
it('should break once found', async function () {
|
||||
it('should resolve relatively', async function () {
|
||||
const loader = new Loader({ relativeReference: true, fs, extname: '' } as any)
|
||||
const candidates = [...loader.candidates('./foo/bar', ['/root', '/root/foo'], '/root/current', true)]
|
||||
expect(candidates.join()).to.equal('/root/foo/bar')
|
||||
expect(candidates).to.contain('/root/foo/bar')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user