Change SHUTTLE_WILL_ARRIVE_AT_STOP to return payload of last stop and current stop, to avoid data race
This commit is contained in:
@@ -734,9 +734,11 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
|
||||
expect(listener).toHaveBeenCalledTimes(1);
|
||||
const emittedPayload = listener.mock.calls[0][0] as any;
|
||||
expect(emittedPayload.shuttleId).toBe(shuttle.id);
|
||||
expect(emittedPayload.stopId).toBe(stop1.id);
|
||||
expect(emittedPayload.timestamp.getTime()).toBe(arrivalTime.getTime());
|
||||
expect(emittedPayload.currentArrival).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop1.id,
|
||||
timestamp: arrivalTime,
|
||||
});
|
||||
});
|
||||
|
||||
test("does not emit event when shuttle is not at a stop", async () => {
|
||||
@@ -786,14 +788,18 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
|
||||
const firstPayload = listener.mock.calls[0][0] as any;
|
||||
expect(firstPayload.shuttleId).toBe(shuttle.id);
|
||||
expect(firstPayload.stopId).toBe(stop1.id);
|
||||
expect(firstPayload.timestamp.getTime()).toBe(firstArrivalTime.getTime());
|
||||
expect(firstPayload.currentArrival).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop1.id,
|
||||
timestamp: firstArrivalTime,
|
||||
});
|
||||
|
||||
const secondPayload = listener.mock.calls[1][0] as any;
|
||||
expect(secondPayload.shuttleId).toBe(shuttle.id);
|
||||
expect(secondPayload.stopId).toBe(stop2.id);
|
||||
expect(secondPayload.timestamp.getTime()).toBe(secondArrivalTime.getTime());
|
||||
expect(secondPayload.currentArrival).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop2.id,
|
||||
timestamp: secondArrivalTime,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user