Changing to use dayjs with timezones in test
This commit is contained in:
parent
ef9925c29e
commit
874ab9f555
1 changed files with 8 additions and 6 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
import { getQueueToken } from '@nestjs/bull'
|
import { getQueueToken } from '@nestjs/bull'
|
||||||
import { Test, TestingModule } from '@nestjs/testing'
|
import { Test, TestingModule } from '@nestjs/testing'
|
||||||
|
import { Dayjs } from 'dayjs'
|
||||||
|
|
||||||
|
import dayjs from '../../../src/common/dayjs'
|
||||||
import { LoggerService } from '../../../src/logger/service.logger'
|
import { LoggerService } from '../../../src/logger/service.logger'
|
||||||
import { NtfyProvider } from '../../../src/ntfy/provider'
|
import { NtfyProvider } from '../../../src/ntfy/provider'
|
||||||
import {
|
import {
|
||||||
|
|
@ -55,7 +57,7 @@ describe('reservations.cron', () => {
|
||||||
let warmupSpy: jest.SpyInstance
|
let warmupSpy: jest.SpyInstance
|
||||||
let reservationsQueueSpy: jest.SpyInstance
|
let reservationsQueueSpy: jest.SpyInstance
|
||||||
let loggerSpy: jest.SpyInstance
|
let loggerSpy: jest.SpyInstance
|
||||||
const loggerInvocationDates: { msg: string; timestamp: Date }[] = []
|
const loggerInvocationDates: { msg: string; timestamp: Dayjs }[] = []
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
jest
|
jest
|
||||||
|
|
@ -85,7 +87,7 @@ describe('reservations.cron', () => {
|
||||||
loggerSpy = jest
|
loggerSpy = jest
|
||||||
.spyOn(module.get<LoggerService>(LoggerService), 'debug')
|
.spyOn(module.get<LoggerService>(LoggerService), 'debug')
|
||||||
.mockImplementation((msg: string) => {
|
.mockImplementation((msg: string) => {
|
||||||
loggerInvocationDates.push({ msg, timestamp: new Date() })
|
loggerInvocationDates.push({ msg, timestamp: dayjs() })
|
||||||
})
|
})
|
||||||
|
|
||||||
jest
|
jest
|
||||||
|
|
@ -108,10 +110,10 @@ describe('reservations.cron', () => {
|
||||||
const { timestamp: goTimeInvocation } =
|
const { timestamp: goTimeInvocation } =
|
||||||
loggerInvocationDates.find(({ msg }) => msg === `It's go-time`) ?? {}
|
loggerInvocationDates.find(({ msg }) => msg === `It's go-time`) ?? {}
|
||||||
expect(goTimeInvocation).toBeDefined()
|
expect(goTimeInvocation).toBeDefined()
|
||||||
expect(goTimeInvocation?.getMilliseconds()).toBeLessThanOrEqual(100)
|
expect(goTimeInvocation?.get('milliseconds')).toBeLessThanOrEqual(100)
|
||||||
expect(goTimeInvocation?.getSeconds()).toEqual(0)
|
expect(goTimeInvocation?.get('seconds')).toEqual(0)
|
||||||
expect(goTimeInvocation?.getMinutes()).toEqual(0)
|
expect(goTimeInvocation?.get('minutes')).toEqual(0)
|
||||||
expect(goTimeInvocation?.getHours()).toEqual(7)
|
expect(goTimeInvocation?.get('hours')).toEqual(7)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should perform reservations', () => {
|
it('should perform reservations', () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue