fix(occupancies): assign room resources during transfers

This commit is contained in:
2026-07-13 12:01:48 +08:00
parent 8cadf8970e
commit 2874ab7bee
6 changed files with 156 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
import { validate } from 'class-validator';
import { CheckInDto, TransferRoomDto } from './occupancy.dto';
describe('manual occupancy DTO bed requirements', () => {
it('requires a bed for manual check-in', async () => {
const dto = Object.assign(new CheckInDto(), {
studentId: 1,
roomId: 2,
checkInDate: '2026-07-13',
});
const errors = await validate(dto);
expect(errors.some((error) => error.property === 'bedId')).toBe(true);
});
it('requires a new bed for a room transfer while keeping the locker optional', async () => {
const dto = Object.assign(new TransferRoomDto(), {
newRoomId: 3,
transferDate: '2026-07-13',
});
const errors = await validate(dto);
expect(errors.some((error) => error.property === 'newBedId')).toBe(true);
expect(errors.some((error) => error.property === 'newLockerId')).toBe(false);
});
});