Files
edr-platform/apps/edr-freight-api/src/modules/train-scheduling/utils/wagon-readiness.util.spec.ts

36 lines
1.1 KiB
TypeScript

import { WagonReadiness } from '@edr/types';
import {
requiredWagonReadiness,
wagonReadinessMatchesSchedule,
} from './wagon-readiness.util';
describe('wagonReadinessMatchesSchedule', () => {
it('requires IMPORT_READY for IMPORT schedules', () => {
expect(requiredWagonReadiness('IMPORT')).toBe(WagonReadiness.ImportReady);
expect(
wagonReadinessMatchesSchedule(WagonReadiness.ImportReady, 'IMPORT'),
).toBe(true);
expect(
wagonReadinessMatchesSchedule(WagonReadiness.ExportReady, 'IMPORT'),
).toBe(false);
});
it('requires EXPORT_READY for EXPORT schedules', () => {
expect(requiredWagonReadiness('EXPORT')).toBe(WagonReadiness.ExportReady);
expect(
wagonReadinessMatchesSchedule(WagonReadiness.ExportReady, 'EXPORT'),
).toBe(true);
expect(
wagonReadinessMatchesSchedule(WagonReadiness.ImportReady, 'EXPORT'),
).toBe(false);
});
it('allows any readiness for DOMESTIC schedules', () => {
expect(requiredWagonReadiness('DOMESTIC')).toBeNull();
expect(
wagonReadinessMatchesSchedule(WagonReadiness.ExportReady, 'DOMESTIC'),
).toBe(true);
});
});