mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix: support integer arithmetic for divided_by, closes #465
This commit is contained in:
@@ -199,6 +199,11 @@ describe('Issues', function () {
|
||||
const html = engine.parseAndRenderSync('{{foo | size}}-{{bar.coo}}', { foo: 'foo', bar: Object.create({ coo: 'COO' }) })
|
||||
expect(html).to.equal('3-')
|
||||
})
|
||||
it('#465 Liquidjs divided_by not compatible with Ruby/Shopify Liquid', () => {
|
||||
const engine = new Liquid({ ownPropertyOnly: true })
|
||||
const html = engine.parseAndRenderSync('{{ 5 | divided_by: 3, true }}')
|
||||
expect(html).to.equal('1')
|
||||
})
|
||||
it('#479 url_encode throws on undefined value', async () => {
|
||||
const engine = new Liquid({
|
||||
strictVariables: false
|
||||
|
||||
@@ -25,6 +25,8 @@ describe('filters/math', function () {
|
||||
it('should return 2 for 4,2', () => test('{{4 | divided_by: 2}}', '2'))
|
||||
it('should return 4 for 16,4', () => test('{{16 | divided_by: 4}}', '4'))
|
||||
it('should return 1 for 5,3', () => test('{{5 | divided_by: 3}}', (5 / 3).toString()))
|
||||
it('should support integer arithmetic', () => test('{{5 | divided_by: 3, true}}', '1'))
|
||||
it('should floor the result in integer arithmetic', () => test('{{ -5 | divided_by: 3, true}}', '-2'))
|
||||
it('should convert string to number', () => test('{{"6" | divided_by: "3"}}', '2'))
|
||||
})
|
||||
describe('floor', function () {
|
||||
|
||||
Reference in New Issue
Block a user