mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: throws when using preserveTimezones on Node.js, fixes #431
This commit is contained in:
+9
-1
@@ -1,4 +1,4 @@
|
||||
import { Liquid } from '../../src/liquid'
|
||||
import { Liquid } from '../..'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import * as sinon from 'sinon'
|
||||
@@ -153,4 +153,12 @@ describe('Issues', function () {
|
||||
expect(exists).to.be.calledOnce
|
||||
expect(readFile).to.be.calledOnce
|
||||
})
|
||||
it('#431 Error when using Date timezoneOffset in 9.28.5', async () => {
|
||||
const engine = new Liquid({
|
||||
timezoneOffset: 0,
|
||||
preserveTimezones: true
|
||||
})
|
||||
const tpl = engine.parse('Welcome to {{ now | date: "%Y-%m-%d" }}!')
|
||||
expect(engine.render(tpl, { now: new Date('2019/02/01') })).to.eventually.equal('Welcome to 2019-02-01')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('filters/date', function () {
|
||||
const scope = { date: new Date('1990-12-31T23:00:00Z') }
|
||||
return test('{{ date | date: "%z"}}', scope, '-0600', opts)
|
||||
})
|
||||
it('should ignore this setting when `preserveTimezones` also specified', function () {
|
||||
it('should work with `preserveTimezones`', function () {
|
||||
const opts: LiquidOptions = { timezoneOffset: 600, preserveTimezones: true }
|
||||
return test('{{ "1990-12-31T23:00:00+02:30" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00', undefined, opts)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user