refactoring and adding capability to recognize more schedules
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
35
tests/repetition.test.ts
Normal file
35
tests/repetition.test.ts
Normal file
@ -0,0 +1,35 @@
|
||||
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)
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user