2021-04-13 21:10:28 +02:00
|
|
|
import test from 'ava'
|
2022-01-09 12:11:24 +01:00
|
|
|
import Formatter from './formatter.js'
|
2021-04-13 21:10:28 +02:00
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatDate one date', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: '2021-04-15T15:30:00Z',
|
|
|
|
})
|
2021-05-05 10:13:16 +02:00
|
|
|
t.is(date, '15/04/2021 10:30 - 15:30')
|
2021-04-13 21:10:28 +02:00
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatDate one date with short offset name', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: '2021-04-15T15:30:00Z',
|
|
|
|
isShortOffsetNameShown: true,
|
|
|
|
})
|
2021-05-23 15:37:29 +02:00
|
|
|
t.is(date, '15/04/2021 10:30 - 15:30 (UTC)')
|
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatDate two dates', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: '2021-04-16T15:30:00Z',
|
|
|
|
})
|
2021-05-05 10:13:16 +02:00
|
|
|
t.is(date, '15/04/2021 10:30 - 16/04/2021 15:30')
|
2021-04-13 21:10:28 +02:00
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatDate two dates with short offset name', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: '2021-04-16T15:30:00Z',
|
|
|
|
isShortOffsetNameShown: true,
|
|
|
|
})
|
2021-12-23 17:16:03 +01:00
|
|
|
t.is(date, '15/04/2021 10:30 - 16/04/2021 15:30 (UTC)')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('#formatDate second date is null', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: null,
|
|
|
|
})
|
|
|
|
t.is(date, '15/04/2021 10:30')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('#formatDate second date is null with short offset name', (t) => {
|
|
|
|
const date = Formatter.formatDate({
|
|
|
|
start: '2021-04-15T10:30:00Z',
|
|
|
|
end: null,
|
|
|
|
isShortOffsetNameShown: true,
|
|
|
|
})
|
|
|
|
t.is(date, '15/04/2021 10:30 (UTC)')
|
2021-05-23 15:37:29 +02:00
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatLocation both parameters', (t) => {
|
2022-01-09 12:54:58 +01:00
|
|
|
const location = Formatter.formatLocation({ description: 'a', locality: 'b' })
|
|
|
|
t.is(location, 'a, b')
|
2021-04-13 21:10:28 +02:00
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatLocation description only', (t) => {
|
2022-01-09 12:54:58 +01:00
|
|
|
const location = Formatter.formatLocation({ description: 'a' })
|
|
|
|
t.is(location, 'a')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('#formatLocation description with space only', (t) => {
|
|
|
|
const location = Formatter.formatLocation({ description: ' ' })
|
|
|
|
t.is(location, '')
|
2021-04-13 21:10:28 +02:00
|
|
|
})
|
|
|
|
|
2021-12-09 19:46:19 +01:00
|
|
|
test('#formatLocation locality only', (t) => {
|
2022-01-09 12:54:58 +01:00
|
|
|
const location = Formatter.formatLocation({ locality: 'a' })
|
|
|
|
t.is(location, 'a')
|
2021-04-13 21:10:28 +02:00
|
|
|
})
|