rollSkipLimit

This commit is contained in:
arc-alex
2023-11-22 19:05:08 +01:00
parent 8cabb347e9
commit e6b4f537af
3 changed files with 66 additions and 2 deletions
@@ -2,6 +2,7 @@ import { OntimeEvent } from 'ontime-types';
import { dayInMs } from 'ontime-utils';
import { getRollTimers, normaliseEndTime, sortArrayByProperty, updateRoll } from '../rollUtils.js';
import { config } from '../../config/config.js';
// test sortArrayByProperty()
describe('sort simple arrays of objects', () => {
@@ -585,6 +586,66 @@ describe('typical scenarios', () => {
expect(updateRoll(timers)).toStrictEqual(expected);
});
it('dose not skip isFinished under limit', () => {
const timers = {
selectedEventId: '1',
current: 13,
_finishAt: 15,
_startAt: 9,
clock: 14,
secondaryTimer: null,
secondaryTarget: null,
};
const expected = {
updatedTimer: timers._finishAt - timers.clock,
updatedSecondaryTimer: null,
doRollLoad: false,
isFinished: false,
};
expect(updateRoll(timers)).toStrictEqual(expected);
// test that it can jump time
timers._finishAt = 14;
timers.clock += config.rollSkipLimit - 1;
expected.updatedTimer = timers._finishAt - timers.clock;
expected.doRollLoad = true;
expected.isFinished = true;
expect(updateRoll(timers)).toStrictEqual(expected);
});
it('dose skips isFinished over limit', () => {
const timers = {
selectedEventId: '1',
current: 13,
_finishAt: 15,
_startAt: 9,
clock: 14,
secondaryTimer: null,
secondaryTarget: null,
};
const expected = {
updatedTimer: timers._finishAt - timers.clock,
updatedSecondaryTimer: null,
doRollLoad: false,
isFinished: false,
};
expect(updateRoll(timers)).toStrictEqual(expected);
// test that it can jump time
timers._finishAt = 14;
timers.clock += config.rollSkipLimit + 1;
expected.updatedTimer = timers._finishAt - timers.clock;
expected.doRollLoad = true;
expected.isFinished = false;
expect(updateRoll(timers)).toStrictEqual(expected);
});
it('it updates secondary timer', () => {
const timers = {
selectedEventId: null,