diff --git a/test/integration/builtin/filters/date.ts b/test/integration/builtin/filters/date.ts index a7f7cdd8a..8353c9be8 100644 --- a/test/integration/builtin/filters/date.ts +++ b/test/integration/builtin/filters/date.ts @@ -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) })