Skip to content

Commit

Permalink
Use path aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfelixrico committed Apr 5, 2024
1 parent 8cc267f commit a598a0f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions server/jest/__tests__/room.service.class.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// TODO support absolute paths. these are a mess.
import { INACTIVITY_THRESHOLD, RoomService } from '../../../server/src/services/room.service/room-service.class'
import { Room } from '../../src/services/room.service/room.class'
import {
INACTIVITY_THRESHOLD,
RoomService,
} from '@/services/room.service/room-service.class'
import { Room } from '@/services/room.service/room.class'

describe('room-service', () => {
it('purges rooms past the inactivity threshold', () => {
const room = new Room('room_id')
// Forces lastActivityTs to be way past the inactivity threshold
jest.spyOn(room, 'lastActivityTs', 'get')
jest
.spyOn(room, 'lastActivityTs', 'get')
.mockReturnValue(Date.now() - INACTIVITY_THRESHOLD * 2)

const service = new RoomService()
Expand All @@ -15,16 +19,18 @@ describe('room-service', () => {
service.rooms['dummy2'] = new Room('dummy2')
service.rooms['dummy3'] = new Room('dummy3')

expect(service.rooms).toEqual(expect.objectContaining({
'room_id': expect.any(Room)
}))
expect(service.rooms).toEqual(
expect.objectContaining({
room_id: expect.any(Room),
})
)
expect(Object.values(service.rooms)).toHaveLength(4)

service.purgeInactiveRooms()

expect(service.rooms).toEqual(
expect.not.objectContaining({
'room_id': expect.any(Room)
room_id: expect.any(Room),
})
)
expect(Object.values(service.rooms)).toHaveLength(3)
Expand Down

0 comments on commit a598a0f

Please sign in to comment.