node-event-bot/tests/repetition.test.ts

36 lines
1.4 KiB
TypeScript
Raw Normal View History

import { findInScheduleTypes } from '../server/helper/typeFind'
import { supportedSchedule } from '../server/types/scheduledEventTypes'
import { getRepetitonInfo } from '../server/handler/repeatingEvents/helper'
import { RepetitonInfo } from '../server/types/scheduledEventTypes'
describe('Schedule names are parsed correctly', () => {
const dailyValue: supportedSchedule = 'daily'
const weeklyValue: supportedSchedule = 'weekly'
const monthlyValue: supportedSchedule = 'monthly'
test('Easy schedule names', () => {
expect(findInScheduleTypes('daily')).toEqual(dailyValue)
expect(findInScheduleTypes('weekly')).toEqual(weeklyValue)
expect(findInScheduleTypes('monthly')).toEqual(monthlyValue)
})
test('Medium schedule names', () => {
expect(findInScheduleTypes('Daily')).toEqual(dailyValue)
expect(findInScheduleTypes('Weekly')).toEqual(weeklyValue)
expect(findInScheduleTypes('Monthly')).toEqual(monthlyValue)
expect(findInScheduleTypes('DAILY')).toEqual(dailyValue)
expect(findInScheduleTypes('WEEKLy')).toEqual(weeklyValue)
expect(findInScheduleTypes('MONTHly')).toEqual(monthlyValue)
})
})
describe('Parsing of Repetition Info from Description String',()=>{
test('Happy Path',()=>{
const inputString = '$rep:daily:1/3'
const expectedInfo: RepetitonInfo = {
totalAmount: 3,
alreadyOccured: 1,
schedule: 'daily'
}
expect(getRepetitonInfo(inputString)).toEqual(expectedInfo)
})
})