chore: use amount const in tests

This commit is contained in:
kolaente 2022-09-29 18:23:07 +02:00
parent 7725de7483
commit 429b8a1ec4
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,6 @@
import {describe, it, expect, vi, afterEach, beforeEach} from 'vitest' import {describe, it, expect, vi, afterEach, beforeEach} from 'vitest'
import { import {
AMOUNTS_IN_SECONDS,
getDefaultReminderSettings, getDefaultReminderSettings,
getSavedReminderSettings, getSavedReminderSettings,
parseSavedReminderAmount, parseSavedReminderAmount,
@ -36,25 +37,25 @@ describe('Default Reminder Save', () => {
describe('Default Reminder Load', () => { describe('Default Reminder Load', () => {
it('Should parse minutes', () => { it('Should parse minutes', () => {
const settings = parseSavedReminderAmount(5 * 60) const settings = parseSavedReminderAmount(5 * AMOUNTS_IN_SECONDS.minutes)
expect(settings.amount).toBe(5) expect(settings.amount).toBe(5)
expect(settings.type).toBe('minutes') expect(settings.type).toBe('minutes')
}) })
it('Should parse hours', () => { it('Should parse hours', () => {
const settings = parseSavedReminderAmount(5 * 60 * 60) const settings = parseSavedReminderAmount(5 * AMOUNTS_IN_SECONDS.hours)
expect(settings.amount).toBe(5) expect(settings.amount).toBe(5)
expect(settings.type).toBe('hours') expect(settings.type).toBe('hours')
}) })
it('Should parse days', () => { it('Should parse days', () => {
const settings = parseSavedReminderAmount(5 * 60 * 60 * 24) const settings = parseSavedReminderAmount(5 * AMOUNTS_IN_SECONDS.days)
expect(settings.amount).toBe(5) expect(settings.amount).toBe(5)
expect(settings.type).toBe('days') expect(settings.type).toBe('days')
}) })
it('Should parse months', () => { it('Should parse months', () => {
const settings = parseSavedReminderAmount(5 * 60 * 60 * 24 * 30) const settings = parseSavedReminderAmount(5 * AMOUNTS_IN_SECONDS.months)
expect(settings.amount).toBe(5) expect(settings.amount).toBe(5)
expect(settings.type).toBe('months') expect(settings.type).toBe('months')

View file

@ -1,6 +1,11 @@
const DEFAULT_REMINDER_KEY = 'defaultReminder' const DEFAULT_REMINDER_KEY = 'defaultReminder'
const AMOUNTS_IN_SECONDS: { [key: string]: number } = { export const AMOUNTS_IN_SECONDS: {
minutes: number,
hours: number,
days: number,
months: number,
} = {
minutes: 60, minutes: 60,
hours: 60 * 60, hours: 60 * 60,
days: 60 * 60 * 24, days: 60 * 60 * 24,