jellyfin-discord-bot/tests/helpers/date.test.ts

16 lines
610 B
TypeScript
Raw Normal View History

2023-06-24 19:56:49 +02:00
import { createDateStringFromEvent } from "../../server/helper/dateHelper"
import MockDate from 'mockdate'
beforeAll(() => {
2023-07-13 22:46:03 +02:00
MockDate.set('01-01-2023')
2023-06-24 19:56:49 +02:00
})
2023-07-13 22:46:03 +02:00
function getTestDate(date: string): Date {
return new Date(date)
2023-06-24 19:56:49 +02:00
}
test('createDateStringFromEvent - correct formatting', () => {
2023-07-13 22:46:03 +02:00
expect(createDateStringFromEvent(getTestDate('01-01-2023 12:30'), "")).toEqual('heute um 12:30')
2023-07-17 22:48:57 +02:00
expect(createDateStringFromEvent(getTestDate('01-02-2023 12:30'), "")).toEqual('am Montag 02.01. um 12:30')
expect(createDateStringFromEvent(getTestDate('01-03-2023 12:30'), "")).toEqual('am Dienstag 03.01. um 12:30')
2023-06-24 19:56:49 +02:00
})