mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: date filters from Jekyll
This commit is contained in:
@@ -146,3 +146,54 @@ describe('filters/date', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('filters/date_to_xmlschema', function () {
|
||||
const liquid = new Liquid()
|
||||
it('should support literal date', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "1990-10-15T23:00:00" | date_to_xmlschema }}')
|
||||
expect(output).toMatch(/^1990-10-15T23:00:00[+-]\d\d:\d\d$/)
|
||||
})
|
||||
it('should timezoned date', function () {
|
||||
const liquid = new Liquid({ preserveTimezones: true })
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_xmlschema }}')
|
||||
expect(output).toEqual('2008-11-07T13:07:54-08:00')
|
||||
})
|
||||
})
|
||||
describe('filters/date_to_rfc822', function () {
|
||||
const liquid = new Liquid()
|
||||
it('should support literal date', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "1990-10-15T23:00:00" | date_to_rfc822 }}')
|
||||
expect(output).toMatch(/^Mon, 15 Oct 1990 23:00:00 [+-]\d{4}$/)
|
||||
})
|
||||
it('should timezoned date', function () {
|
||||
const liquid = new Liquid({ preserveTimezones: true })
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_rfc822 }}')
|
||||
expect(output).toEqual('Fri, 07 Nov 2008 13:07:54 -0800')
|
||||
})
|
||||
})
|
||||
describe('filters/date_to_string', function () {
|
||||
const liquid = new Liquid({ preserveTimezones: true })
|
||||
it('should default to non-ordinal, UK', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_string }}')
|
||||
expect(output).toEqual('07 Nov 2008')
|
||||
})
|
||||
it('should support ordinal, US', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_string: "ordinal", "US" }}')
|
||||
expect(output).toEqual('Nov 7th, 2008')
|
||||
})
|
||||
})
|
||||
|
||||
describe('filters/date_to_long_string', function () {
|
||||
const liquid = new Liquid({ preserveTimezones: true })
|
||||
it('should default to non-ordinal, UK', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_long_string }}')
|
||||
expect(output).toEqual('07 November 2008')
|
||||
})
|
||||
it('should support ordinal, US', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_long_string: "ordinal", "US" }}')
|
||||
expect(output).toEqual('November 7th, 2008')
|
||||
})
|
||||
it('should support ordinal, UK', function () {
|
||||
const output = liquid.parseAndRenderSync('{{ "2008-11-07T13:07:54-08:00" | date_to_long_string: "ordinal" }}')
|
||||
expect(output).toEqual('7th November 2008')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user