mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-01 04:19:12 +00:00
refactor: fix delay positioning in gaps
This commit is contained in:
committed by
Carlos Valente
parent
68175cfa3b
commit
030c8f897f
@@ -170,6 +170,73 @@ describe('generate()', () => {
|
||||
expect(initResult.totalDuration).toBe(dayInMs + MILLIS_PER_HOUR); // day + last end - first start
|
||||
});
|
||||
|
||||
it('maintains delays over gaps', () => {
|
||||
const rundown = makeRundown({
|
||||
order: ['1', 'delay', '2'],
|
||||
entries: {
|
||||
'1': makeOntimeEvent({ id: '1', timeStart: 0, timeEnd: 100, duration: 100 }),
|
||||
delay: makeOntimeDelay({ id: 'delay', duration: 500 }),
|
||||
'2': makeOntimeEvent({ id: '2', timeStart: 500, timeEnd: 600, duration: 100 }),
|
||||
},
|
||||
});
|
||||
|
||||
const initResult = generate(rundown, {});
|
||||
expect(initResult.entries['2']).toMatchObject({
|
||||
gap: 400,
|
||||
delay: 500,
|
||||
});
|
||||
expect(initResult.totalDelay).toBe(500);
|
||||
expect(initResult.totalDuration).toBe(600);
|
||||
});
|
||||
|
||||
it('maintains delays over gaps when there are cumulative delays', () => {
|
||||
const rundown = makeRundown({
|
||||
order: ['delay1', '1', 'delay2', '2'],
|
||||
entries: {
|
||||
delay1: makeOntimeDelay({ id: 'delay', duration: 100 }),
|
||||
'1': makeOntimeEvent({ id: '1', timeStart: 0, timeEnd: 100, duration: 100 }),
|
||||
delay2: makeOntimeDelay({ id: 'delay', duration: 300 }),
|
||||
'2': makeOntimeEvent({ id: '2', timeStart: 300, timeEnd: 400, duration: 100 }),
|
||||
},
|
||||
});
|
||||
|
||||
const initResult = generate(rundown, {});
|
||||
expect(initResult.entries['1']).toMatchObject({
|
||||
gap: 0,
|
||||
delay: 100,
|
||||
});
|
||||
expect(initResult.entries['2']).toMatchObject({
|
||||
gap: 200,
|
||||
delay: 300, // first delay was fully absorbed
|
||||
});
|
||||
expect(initResult.totalDelay).toBe(300);
|
||||
expect(initResult.totalDuration).toBe(400);
|
||||
});
|
||||
|
||||
it('handles negative delays on gaps', () => {
|
||||
const rundown = makeRundown({
|
||||
order: ['delay1', '1', 'delay2', '2'],
|
||||
entries: {
|
||||
delay1: makeOntimeDelay({ id: 'delay', duration: -100 }),
|
||||
'1': makeOntimeEvent({ id: '1', timeStart: 0, timeEnd: 100, duration: 100 }),
|
||||
delay2: makeOntimeDelay({ id: 'delay', duration: -300 }),
|
||||
'2': makeOntimeEvent({ id: '2', timeStart: 300, timeEnd: 400, duration: 100 }),
|
||||
},
|
||||
});
|
||||
|
||||
const initResult = generate(rundown, {});
|
||||
expect(initResult.entries['1']).toMatchObject({
|
||||
gap: 0,
|
||||
delay: -100,
|
||||
});
|
||||
expect(initResult.entries['2']).toMatchObject({
|
||||
gap: 200,
|
||||
delay: -400,
|
||||
});
|
||||
expect(initResult.totalDelay).toBe(-400);
|
||||
expect(initResult.totalDuration).toBe(400);
|
||||
});
|
||||
|
||||
it('handles negative delays', () => {
|
||||
const rundown = makeRundown({
|
||||
order: ['1', 'delay', '2', 'block', '3', 'another-block', '4'],
|
||||
|
||||
Reference in New Issue
Block a user