chore: fix date tests

This commit is contained in:
Mo
2022-12-01 07:05:02 -06:00
parent 1ee6be4e5c
commit 73ca12275f
6 changed files with 31 additions and 20 deletions

View File

@@ -1,15 +1,16 @@
import { dateFromDSLDateString } from './Utils'
import { addDaysToDate, addHoursToDate } from '@standardnotes/utils'
describe('Predicate Utils', () => {
describe('dateFromDSLDateString', () => {
it('should return a date object with the correct day', () => {
const date = dateFromDSLDateString('1.days.ago')
expect(date.getDate()).toEqual(new Date().getDate() - 1)
expect(date.getDate()).toEqual(addDaysToDate(new Date(), -1).getDate())
})
it('should return a date object with the correct hour', () => {
const date = dateFromDSLDateString('1.hours.ago')
expect(date.getHours()).toEqual(new Date().getHours() - 1)
expect(date.getHours()).toEqual(addHoursToDate(new Date(), -1).getHours())
})
it('should return a date object with the correct month', () => {