connector-wordpress/source/connector-mobilizon/front/date-time-wrapper-test.js

54 lines
1.9 KiB
JavaScript
Raw Normal View History

import test from 'ava'
2021-04-13 20:50:56 +02:00
import DateTimeWrapper from './date-time-wrapper'
2021-01-08 14:08:40 +01:00
test('#getShortDate usual date', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
2021-01-08 14:08:40 +01:00
t.is(d.getShortDate(), '24/12/2020')
})
test('#get24Time usual time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
t.is(d.get24Time(), '17:45')
2021-01-08 14:08:40 +01:00
})
test('#equalsDate same date, different time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T17:46:01Z' })
2021-01-08 14:08:40 +01:00
t.true(d.equalsDate(e))
})
test('#equalsDate different date, different time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
const e = new DateTimeWrapper({ locale: 'en-GB', text: '2021-11-25T17:46:01Z' })
2021-01-08 14:08:40 +01:00
t.false(d.equalsDate(e))
})
test('#equalsDate different day, different time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-25T17:46:01Z' })
2021-01-08 14:08:40 +01:00
t.false(d.equalsDate(e))
})
test('#equalsDate different month, different time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
const e = new DateTimeWrapper({ locale: 'en-GB', text: '2020-11-24T17:46:01Z' })
2021-01-08 14:08:40 +01:00
t.false(d.equalsDate(e))
})
test('#equalsDate different year, different time', t => {
2021-05-04 11:16:18 +02:00
const d = new DateTimeWrapper({ locale: 'en-GB', text: '2020-12-24T16:45:00Z' })
const e = new DateTimeWrapper({ locale: 'en-GB', text: '2021-12-24T17:46:01Z' })
2021-01-08 14:08:40 +01:00
t.false(d.equalsDate(e))
})
test('#getCurrentDatetimeAsString correct format', t => {
const d = DateTimeWrapper.getCurrentDatetimeAsString()
t.is(d[4], '-')
t.is(d[7], '-')
t.is(d[10], 'T')
t.is(d[13], ':')
t.is(d[16], ':')
t.is(d[19], '.')
t.is(d[d.length-3], ':')
})