Files
liquidjs/test/e2e/drop.ts
T
harttle b4acdb463a fix: math filters now return number, resolves #110
* fix linting
* numbers are no longer fixed:
    i.e. {{0.3 | minus 0.1}} now renders as 0.19999
    Stick to JavaScript number behavior, see: 8.0.0
2019-02-28 13:02:51 +08:00

41 lines
1.1 KiB
TypeScript

import Liquid from '../..'
import { expect, use } from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
use(chaiAsPromised)
class SettingsDrop extends Liquid.Types.Drop {
foo: string = 'FOO'
bar () {
return 'BAR'
}
liquidMethodMissing (key: string) {
return key.toUpperCase()
}
}
describe('drop', function () {
const settings = new SettingsDrop()
let engine: Liquid
beforeEach(function () {
engine = new Liquid()
})
it('should support liquidMethodMissing', async function () {
const src = `{{settings.foo}},{{settings.bar}},{{settings.coo}}`
const html = await engine.parseAndRender(src, { settings })
return expect(html).to.equal('FOO,BAR,COO')
})
describe('BlandDrop', function () {
it('should test blank strings', async function () {
const src = `
{% unless settings.fp_heading == blank %}
<h1>{{ settings.fp_heading }}</h1>
{% endunless %}`
var ctx = { settings: { fp_heading: '' } }
const html = await engine.parseAndRender(src, ctx)
return expect(html).to.match(/^\s+$/)
})
})
})