Fix tests failing on thursdays

This commit is contained in:
kolaente 2021-07-09 09:48:33 +02:00
parent 21e96a08c9
commit 096fc0bbc8
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -168,7 +168,6 @@ describe('Parse Task Text', () => {
const nextThursday = new Date() const nextThursday = new Date()
nextThursday.setDate(nextThursday.getDate() + ((4 + 7 - nextThursday.getDay()) % 7)) nextThursday.setDate(nextThursday.getDate() + ((4 + 7 - nextThursday.getDay()) % 7))
expect(`${result.date.getFullYear()}-${result.date.getMonth()}-${result.date.getDate()}`).toBe(`${nextThursday.getFullYear()}-${nextThursday.getMonth()}-${nextThursday.getDate()}`) expect(`${result.date.getFullYear()}-${result.date.getMonth()}-${result.date.getDate()}`).toBe(`${nextThursday.getFullYear()}-${nextThursday.getMonth()}-${nextThursday.getDate()}`)
expect(+new Date(result.date)).toBeGreaterThan(+new Date() - 10) // In on thursdays, this may be different by one second and thus fails the test
}) })
it('should recognize weekdays with time', () => { it('should recognize weekdays with time', () => {
const result = parseTaskText('Lorem Ipsum thu at 14:00') const result = parseTaskText('Lorem Ipsum thu at 14:00')
@ -178,7 +177,6 @@ describe('Parse Task Text', () => {
nextThursday.setDate(nextThursday.getDate() + ((4 + 7 - nextThursday.getDay()) % 7)) nextThursday.setDate(nextThursday.getDate() + ((4 + 7 - nextThursday.getDay()) % 7))
expect(`${result.date.getFullYear()}-${result.date.getMonth()}-${result.date.getDate()}`).toBe(`${nextThursday.getFullYear()}-${nextThursday.getMonth()}-${nextThursday.getDate()}`) expect(`${result.date.getFullYear()}-${result.date.getMonth()}-${result.date.getDate()}`).toBe(`${nextThursday.getFullYear()}-${nextThursday.getMonth()}-${nextThursday.getDate()}`)
expect(`${result.date.getHours()}:${result.date.getMinutes()}`).toBe('14:0') expect(`${result.date.getHours()}:${result.date.getMinutes()}`).toBe('14:0')
expect(+new Date(result.date)).toBeGreaterThan(+new Date() - 10) // In on thursdays, this may be different by one second and thus fails the test
}) })
it('should recognize dates of the month in the past but next month', () => { it('should recognize dates of the month in the past but next month', () => {
const date = new Date() const date = new Date()