mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
This commit is contained in:
@@ -85,6 +85,17 @@ describe('tags/layout', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('XAY')
|
||||
})
|
||||
it('should use `layouts` if specified', async function () {
|
||||
mock({
|
||||
'/layouts/parent.html': 'LAYOUTS {%block%}{%endblock%}',
|
||||
'/root/parent.html': 'ROOT {%block%}{%endblock%}',
|
||||
'/root/main.html': '{% layout parent.html %}{%block%}A{%endblock%}'
|
||||
})
|
||||
const staticLiquid = new Liquid({ root: '/root', layouts: '/layouts', dynamicPartials: false })
|
||||
const html = await staticLiquid.renderFile('main.html')
|
||||
return expect(html).to.equal('LAYOUTS A')
|
||||
})
|
||||
|
||||
it('should support block.super', async function () {
|
||||
mock({
|
||||
'/parent.html': '{% block css %}<link href="base.css" rel="stylesheet">{% endblock %}'
|
||||
@@ -189,6 +200,16 @@ describe('tags/layout', function () {
|
||||
return expect(html).to.equal('blackA')
|
||||
})
|
||||
|
||||
it('should support relative root', async function () {
|
||||
mock({
|
||||
[process.cwd() + '/foo/parent.html']: '{{color}}{%block%}{%endblock%}',
|
||||
[process.cwd() + '/foo/bar/main.html']: '{% layout parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
})
|
||||
const staticLiquid = new Liquid({ root: './foo', dynamicPartials: false })
|
||||
const html = await staticLiquid.renderFile('bar/main.html')
|
||||
return expect(html).to.equal('blackA')
|
||||
})
|
||||
|
||||
describe('static partial', function () {
|
||||
it('should support filename with extension', async function () {
|
||||
mock({
|
||||
|
||||
@@ -3,13 +3,9 @@ import { expect } from 'chai'
|
||||
|
||||
describe('liquid-options', () => {
|
||||
describe('.normalize()', () => {
|
||||
it('should return plain object for empty input', () => {
|
||||
const options = normalize()
|
||||
expect(JSON.stringify(options)).to.equal('{}')
|
||||
})
|
||||
it('should set falsy cache to undefined', () => {
|
||||
it('should set cache to undefined if specified to falsy', () => {
|
||||
const options = normalize({ cache: false })
|
||||
expect(JSON.stringify(options)).to.equal('{}')
|
||||
expect(options.cache).to.equal(undefined)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user