import { Schedule } from "../server/types/scheduledEventTypes" test('multiplier is parsed', () => { const schedule = new Schedule('every3weeks') const multi = schedule.getMultiplierFromVariableString() expect(multi).toEqual(3) }) test('get duration 3 weeks', () => { const schedule = new Schedule('every3weeks') const duration = schedule.calculateDuration() expect(duration).toEqual({ weeks: 3 }) }) test('get duration 4 years', () => { const schedule = new Schedule('every4years') const duration = schedule.calculateDuration() expect(duration).toEqual({ years: 4 }) }) test('get duration 27 days', () => { const schedule = new Schedule('every27days') const duration = schedule.calculateDuration() expect(duration).toEqual({ days: 27 }) }) describe('get new Dates', () => { test('every 27 days', () => { const schedule = new Schedule('every27days') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-01-28') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 2 weeks', () => { const schedule = new Schedule('every2weeks') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-01-15') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 1 month', () => { const schedule = new Schedule('every1months') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-02-01') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 4 year', () => { const schedule = new Schedule('every4years') const oldDate = new Date('2022-01-01') const newDate = new Date('2026-01-01') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 2 days', () => { const schedule = new Schedule('every2days') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-01-03') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 2 days', () => { const schedule = new Schedule('Every2DAys') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-01-03') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) test('every 2 day[s]', () => { const schedule = new Schedule('Every2DAy') const oldDate = new Date('2022-01-01') const newDate = new Date('2022-01-03') expect(schedule.getNewDate(oldDate)).toEqual(newDate) }) })