mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 04:15:43 +00:00
test batch system
This commit is contained in:
@@ -74,6 +74,24 @@ describe('train-capacity.util', () => {
|
||||
expect(derived.maxWeightTons).toBe(3590);
|
||||
});
|
||||
|
||||
it('reports the base caps and tolerance separately so filling can budget on base', () => {
|
||||
const derived = deriveTrainCapacityFromLocomotive(
|
||||
{
|
||||
maxPullWeightTons: 3500,
|
||||
maxTrainLengthMeters: 760,
|
||||
overageToleranceTons: 90,
|
||||
overageToleranceMeters: 20,
|
||||
},
|
||||
[pw2],
|
||||
);
|
||||
expect(derived.baseWeightTons).toBe(3500);
|
||||
expect(derived.baseLengthMeters).toBe(760);
|
||||
expect(derived.toleranceTons).toBe(90);
|
||||
expect(derived.toleranceMeters).toBe(20);
|
||||
expect(derived.baseWeightTons + derived.toleranceTons).toBe(derived.maxWeightTons);
|
||||
expect(derived.baseLengthMeters + derived.toleranceMeters).toBe(derived.maxLengthMeters);
|
||||
});
|
||||
|
||||
it('ignores overage tolerance when unset (strict cap)', () => {
|
||||
const derived = deriveTrainCapacityFromLocomotive(
|
||||
{ maxPullWeightTons: 3500, maxTrainLengthMeters: 760 },
|
||||
@@ -235,5 +253,47 @@ describe('train-capacity.util', () => {
|
||||
sizePartialOfferWagons({ wagons: 5, weightTons: 20, lengthMeters: 500 }, 15, pw2),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
describe('fullWagonsOnly (bulk)', () => {
|
||||
it('offers only whole full wagons — each costs capacity + tare of gross room', () => {
|
||||
// 704T of pull weight left. A full PW2 wagon is 70 + 25.2 = 95.2T gross,
|
||||
// so 7 fit (666.4T) and the 8th (761.6T) does not. Cargo is exactly
|
||||
// 7 × 70 = 490T — the last wagon is never part-loaded into the leftover.
|
||||
const offer = sizePartialOfferWagons(
|
||||
{ wagons: 40, weightTons: 704, lengthMeters: 500 },
|
||||
9,
|
||||
pw2,
|
||||
{ fullWagonsOnly: true },
|
||||
);
|
||||
expect(offer).toEqual({ wagons: 7, maxCargoTons: 490 });
|
||||
});
|
||||
|
||||
it('never squeezes a part-loaded wagon into leftover weight room', () => {
|
||||
// Same 744T room as the part-load scenario above: the scan would pick
|
||||
// 8 wagons hauling 542.4T (last wagon at 52.4/70). Full-wagon sizing
|
||||
// stops at 7 fully loaded wagons.
|
||||
const offer = sizePartialOfferWagons(
|
||||
{ wagons: 40, weightTons: 744, lengthMeters: 500 },
|
||||
15,
|
||||
pw2,
|
||||
{ fullWagonsOnly: true },
|
||||
);
|
||||
expect(offer).toEqual({ wagons: 7, maxCargoTons: 490 });
|
||||
});
|
||||
|
||||
it('returns null when the room cannot take even one FULL wagon', () => {
|
||||
// 67.6T left (3590 cap − 3522.4 boarded): a part-loaded wagon would fit
|
||||
// (25.2 tare + 42.4 cargo) but a full one (95.2 gross) does not — the
|
||||
// booking must be skipped entirely, not trimmed onto the train.
|
||||
expect(
|
||||
sizePartialOfferWagons(
|
||||
{ wagons: 40, weightTons: 67.6, lengthMeters: 500 },
|
||||
3,
|
||||
pw2,
|
||||
{ fullWagonsOnly: true },
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user