fix: ignore 0 duration events

This commit is contained in:
Carlos Valente
2024-09-04 20:29:21 +02:00
committed by Carlos Valente
parent a3020ef3b2
commit b9db08089f
2 changed files with 40 additions and 0 deletions
@@ -280,6 +280,42 @@ describe('loadRoll() handle rundowns with several days', () => {
expect(state).toMatchObject(expected);
});
it('should find the correct event, when we have events of zero duration', () => {
const now = 20 * MILLIS_PER_HOUR + 37 * MILLIS_PER_MINUTE;
const timedEvents = [
{
id: '0',
timeStart: 18 * MILLIS_PER_HOUR,
timeEnd: 19 * MILLIS_PER_HOUR,
},
{
id: '1 no duration',
timeStart: 0,
timeEnd: 0,
},
{
id: '2',
timeStart: 19 * MILLIS_PER_HOUR,
timeEnd: 20 * MILLIS_PER_HOUR,
},
{
id: '3 no duration',
timeStart: 0,
timeEnd: 0,
},
{
id: '4',
timeStart: 20 * MILLIS_PER_HOUR,
timeEnd: 21 * MILLIS_PER_HOUR,
},
];
const state = loadRoll(prepareTimedEvents(timedEvents), now);
const expected = {
event: timedEvents[4],
index: 4,
};
expect(state).toMatchObject(expected);
});
});
+4
View File
@@ -31,6 +31,10 @@ export function loadRoll(
continue;
}
if (event.duration === 0) {
continue;
}
// we check if event crosses midnight
if (event.timeStart > event.timeEnd) {
daySpan++;