forked from wangziqi/gongxue-base
23 lines
880 B
TypeScript
23 lines
880 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { getInitialPresentOccupancyIds, togglePresentOccupancy } from './inspection-state';
|
|
|
|
describe('room inspection state', () => {
|
|
const occupants = [
|
|
{ occupancyId: 11, inspectionStatus: 'present' as const },
|
|
{ occupancyId: 12, inspectionStatus: 'absent' as const },
|
|
];
|
|
|
|
it('starts every occupant unchecked before the room is submitted', () => {
|
|
expect(getInitialPresentOccupancyIds(occupants, false)).toEqual([]);
|
|
});
|
|
|
|
it('restores the saved present occupants after submission', () => {
|
|
expect(getInitialPresentOccupancyIds(occupants, true)).toEqual([11]);
|
|
});
|
|
|
|
it('adds and removes a single occupant without changing the others', () => {
|
|
expect(togglePresentOccupancy([11], 12, true).sort()).toEqual([11, 12]);
|
|
expect(togglePresentOccupancy([11, 12], 11, false)).toEqual([12]);
|
|
});
|
|
});
|