mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
chore: try to make unit test locale independent
This commit is contained in:
@@ -23,19 +23,23 @@ describe('filters/date', function () {
|
||||
it('should render object as string if not valid', function () {
|
||||
return test('{{ obj | date: "%Y"}}', '[object Object]')
|
||||
})
|
||||
it('should create from number-like string', async function () {
|
||||
const src = '{{ "1488859200" | date: "%Y-%m-%dT%H:%M:%S" }}'
|
||||
const dst = '2017-03-07T12:00:00'
|
||||
expect(await liquid.parseAndRender(src)).to.equal(dst)
|
||||
})
|
||||
it('should create from number', async function () {
|
||||
const src = '{{ 1488859200 | date: "%Y-%m-%dT%H:%M:%S" }}'
|
||||
const time = new Date('2017-03-07T12:00:00').getTime() / 1000
|
||||
const src = '{{ time | date: "%Y-%m-%dT%H:%M:%S" }}'
|
||||
const ctx = { time }
|
||||
const dst = '2017-03-07T12:00:00'
|
||||
expect(await liquid.parseAndRender(src)).to.equal(dst)
|
||||
expect(await liquid.parseAndRender(src, ctx)).to.equal(dst)
|
||||
})
|
||||
it('should create from number-like string', async function () {
|
||||
const time = String(new Date('2017-03-07T12:00:00').getTime() / 1000)
|
||||
const src = '{{ time | date: "%Y-%m-%dT%H:%M:%S" }}'
|
||||
const ctx = { time }
|
||||
const dst = '2017-03-07T12:00:00'
|
||||
expect(await liquid.parseAndRender(src, ctx)).to.equal(dst)
|
||||
})
|
||||
it('should support manipulation', async function () {
|
||||
const src = '{{ date | date: "%s" | minus : 604800 | date: "%Y-%m-%dT%H:%M:%S"}}'
|
||||
const ctx = { date: new Date('2017-03-07 12:00:00.000+8:00') }
|
||||
const ctx = { date: new Date('2017-03-07T12:00:00') }
|
||||
const dst = '2017-02-28T12:00:00'
|
||||
expect(await liquid.parseAndRender(src, ctx)).to.equal(dst)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user