Skip to content

Commit 01361b9

Browse files
committed
front: add unit test for first waypoint with arrival time
1 parent 918eff3 commit 01361b9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

front/src/applications/operationalStudies/views/Scenario/components/ManageTrainSchedule/helpers/__tests__/formatTrainSchedulePayload.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,28 @@ describe('formatTrainSchedulePayload', () => {
133133
expect(newTrainSchedulePayload.rolling_stock_name).toBe('rollingStock1');
134134
});
135135
});
136+
137+
describe('The new origin has an arrival time (origin was deleted)', () => {
138+
it('should fold the first waypoint arrival into the start time and shift the others', () => {
139+
const osrdconf: OperationalStudiesConfState = {
140+
...rawOsrdconf,
141+
pathSteps: [
142+
{ ...rawOsrdconf.pathSteps[0]!, arrival: Duration.parse('PT10M') },
143+
{ ...rawOsrdconf.pathSteps[1]!, arrival: Duration.parse('PT25M') },
144+
],
145+
};
146+
147+
const payload = formatTrainSchedulePayload(osrdconf);
148+
149+
expect(payload.start_time).toBe(new Date('2025-06-02T12:55:00.000Z').getTime());
150+
expect(payload.schedule).toEqual([
151+
{
152+
at: '1-1',
153+
arrival: 'PT15M',
154+
reception_signal: 'OPEN',
155+
stop_for: undefined,
156+
},
157+
]);
158+
});
159+
});
136160
});

0 commit comments

Comments
 (0)