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

17 lines
720 B
TypeScript
Raw Normal View History

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