Deps migration (#1988)

* chore: migrate eslint to oxlint

* chore: migrate prettier to oxfmt

* chore: migrate typescript

* chore: toThrow should have a expected value

* chore: cast test value as Day

* chore: small title fix

* chore: mocks should be hoisted

* chore: incorrect async useage

* chore: test should be inside description

* chore: test sohuld include an expeced

* chore: oxfmt

---------

Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
This commit is contained in:
Carlos Valente
2026-03-08 16:22:12 +01:00
committed by GitHub
parent 9516ac21bb
commit 1849b4d39f
501 changed files with 2678 additions and 4654 deletions
-2
View File
@@ -1,2 +0,0 @@
node_modules
dist
-16
View File
@@ -1,16 +0,0 @@
{
"env": {
"browser": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["simple-import-sort", "@typescript-eslint"],
"rules": {
"simple-import-sort/imports": "error",
"@typescript-eslint/consistent-type-imports": "error"
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"$schema": "../../node_modules/oxlint/configuration_schema.json",
"extends": ["../../.oxlintrc.json"],
"plugins": ["unicorn", "typescript", "oxc", "vitest"]
}
-9
View File
@@ -1,9 +0,0 @@
{
"endOfLine": "lf",
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"printWidth": 120
}
+1 -8
View File
@@ -5,7 +5,7 @@
"private": true,
"description": "shared logic for ontime",
"scripts": {
"lint": "eslint . --quiet",
"lint": "oxlint --quiet --type-aware",
"test": "vitest",
"test:pipeline": "vitest run"
},
@@ -14,14 +14,7 @@
"nanoid": "^5.0.7"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"eslint": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-plugin-prettier": "catalog:",
"eslint-plugin-simple-import-sort": "^8.0.0",
"ontime-types": "workspace:*",
"prettier": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
},
@@ -1,52 +1,54 @@
import { Day } from 'ontime-types';
import { checkIsNextDay } from './checkIsNextDay';
import { MILLIS_PER_HOUR } from './conversionUtils';
describe('checkIsNextDay', () => {
it('returns false if there is no previous event', () => {
const current = { timeStart: 0, dayOffset: 0 };
const current = { timeStart: 0, dayOffset: 0 as Day };
const previous = null;
expect(checkIsNextDay(current, previous)).toBeFalsy();
});
it('returns false if event starts after one before', () => {
const current = { timeStart: 11, dayOffset: 0 };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 };
const current = { timeStart: 11, dayOffset: 0 as Day };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 as Day };
expect(checkIsNextDay(current, previous)).toBeFalsy();
});
it('returns true if event starts after one before', () => {
const current = { timeStart: 9, dayOffset: 1 };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 };
const current = { timeStart: 9, dayOffset: 1 as Day };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 as Day };
expect(checkIsNextDay(current, previous)).toBeTruthy();
});
it('returns true if event starts at the same time as one before', () => {
const current = { timeStart: 10, dayOffset: 1 };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 };
const current = { timeStart: 10, dayOffset: 1 as Day };
const previous = { timeStart: 10, duration: 2, dayOffset: 0 as Day };
expect(checkIsNextDay(current, previous)).toBeTruthy();
});
it('should account for an event that crossed midnight', () => {
const current = { timeStart: 1 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 }; // event finished at 02:00:00
const current = { timeStart: 1 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 as Day }; // event finished at 02:00:00
expect(checkIsNextDay(current, previous)).toBeFalsy();
});
it('should account for an event that crossed midnight and there is a gap', () => {
const current = { timeStart: 2 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 }; // event finished at 01:00:00
const current = { timeStart: 2 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 as Day }; // event finished at 01:00:00
expect(checkIsNextDay(current, previous)).toBeFalsy();
});
it('should account for an event that crossed midnight with no overlaps', () => {
const current = { timeStart: 19 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 }; // event finished at 02:00:00
const current = { timeStart: 19 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 as Day }; // event finished at 02:00:00
expect(checkIsNextDay(current, previous)).toBeFalsy();
});
it('should account for an event that finishes exactly at midnight', () => {
const current = { timeStart: 2 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 1 * MILLIS_PER_HOUR, dayOffset: 0 }; // event finished at 24:00:00
const current = { timeStart: 2 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 1 * MILLIS_PER_HOUR, dayOffset: 0 as Day }; // event finished at 24:00:00
expect(checkIsNextDay(current, previous)).toBeTruthy();
});
});
@@ -1,6 +1,6 @@
import { OffsetMode } from 'ontime-types';
import { Day, OffsetMode } from 'ontime-types';
import { dayInMs, MILLIS_PER_HOUR } from './conversionUtils';
import { MILLIS_PER_HOUR, dayInMs } from './conversionUtils';
import { getExpectedStart } from './getExpectedStart';
describe('getExpectedStart()', () => {
@@ -9,7 +9,7 @@ describe('getExpectedStart()', () => {
const testEvent = {
timeStart: 100,
delay: 0,
dayOffset: 0,
dayOffset: 0 as Day,
};
const testState = {
currentDay: 0,
@@ -27,7 +27,7 @@ describe('getExpectedStart()', () => {
test('running behind', () => {
const testEvent = {
timeStart: 100,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -46,7 +46,7 @@ describe('getExpectedStart()', () => {
test('running ahead', () => {
const testEvent = {
timeStart: 100,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -65,7 +65,7 @@ describe('getExpectedStart()', () => {
test('running behind with enough gaps', () => {
const testEvent = {
timeStart: 100,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -84,7 +84,7 @@ describe('getExpectedStart()', () => {
test('running behind with too little gaps', () => {
const testEvent = {
timeStart: 100,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -120,13 +120,13 @@ describe('getExpectedStart()', () => {
//event 2
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent2 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent2 },
{ ...testState, isLinkedToLoaded: true },
),
).toBe(110);
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent2 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent2 },
{ ...testState, isLinkedToLoaded: false },
),
).toBe(110);
@@ -134,13 +134,13 @@ describe('getExpectedStart()', () => {
//event 3
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent3 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent3 },
{ ...testState, isLinkedToLoaded: true },
),
).toBe(120);
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent3 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent3 },
{ ...testState, isLinkedToLoaded: false },
),
).toBe(120);
@@ -151,13 +151,13 @@ describe('getExpectedStart()', () => {
//event 2
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent2 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent2 },
{ ...testState, isLinkedToLoaded: true },
),
).toBe(115);
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent2 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent2 },
{ ...testState, isLinkedToLoaded: false },
),
).toBe(115);
@@ -165,13 +165,13 @@ describe('getExpectedStart()', () => {
//event 3
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent3 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent3 },
{ ...testState, isLinkedToLoaded: true },
),
).toBe(125);
expect(
getExpectedStart(
{ dayOffset: 0, delay: 0, timeStart: timeStartEvent3 },
{ dayOffset: 0 as Day, delay: 0, timeStart: timeStartEvent3 },
{ ...testState, isLinkedToLoaded: false },
),
).toBe(125);
@@ -180,7 +180,7 @@ describe('getExpectedStart()', () => {
test('gaps', () => {
const testEvent = {
timeStart: 20,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -204,7 +204,7 @@ describe('getExpectedStart()', () => {
test('added/remove time', () => {
const testEvent = {
timeStart: 20,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -242,7 +242,7 @@ describe('getExpectedStart()', () => {
// this event will start the current day
expect(
getExpectedStart(
{ timeStart: 10, delay: 0, dayOffset: 0 },
{ timeStart: 10, delay: 0, dayOffset: 0 as Day },
{ ...testState, totalGap: 0, isLinkedToLoaded: false },
),
).toBe(110);
@@ -252,7 +252,7 @@ describe('getExpectedStart()', () => {
// but in relative mode with and actual start that is 100 offset it starts in dayInMs
expect(
getExpectedStart(
{ timeStart: 0, delay: 0, dayOffset: 1 },
{ timeStart: 0, delay: 0, dayOffset: 1 as Day },
{ ...testState, totalGap: dayInMs - 20, isLinkedToLoaded: false },
),
).toBe(dayInMs + 100);
@@ -262,7 +262,7 @@ describe('getExpectedStart()', () => {
test('overlap with negative total gap', () => {
const testEvent = {
timeStart: 5,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -281,7 +281,7 @@ describe('getExpectedStart()', () => {
test('we started on the day before', () => {
const testEvent = {
timeStart: 5,
dayOffset: 0,
dayOffset: 0 as Day,
delay: 0,
};
const testState = {
@@ -299,7 +299,7 @@ describe('getExpectedStart()', () => {
test('next day in multi-day rundown', () => {
const testEvent = {
timeStart: 5,
dayOffset: 1,
dayOffset: 1 as Day,
delay: 0,
};
const testState = {
@@ -1,4 +1,6 @@
import { dayInMs, MILLIS_PER_HOUR, MILLIS_PER_MINUTE } from './conversionUtils';
import { Day } from 'ontime-types';
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, dayInMs } from './conversionUtils';
import { getTimeFrom } from './getTimeFrom';
describe('getTimeFrom', () => {
@@ -6,28 +8,36 @@ describe('getTimeFrom', () => {
const expected = 75600000 - 71700000; // current start - previousEnd
expect(
getTimeFrom(
{ timeStart: 21 * MILLIS_PER_HOUR, dayOffset: 0 },
{ timeStart: 19 * MILLIS_PER_HOUR + 20 * MILLIS_PER_MINUTE, duration: 35 * MILLIS_PER_MINUTE, dayOffset: 0 },
{ timeStart: 21 * MILLIS_PER_HOUR, dayOffset: 0 as Day },
{
timeStart: 19 * MILLIS_PER_HOUR + 20 * MILLIS_PER_MINUTE,
duration: 35 * MILLIS_PER_MINUTE,
dayOffset: 0 as Day,
},
),
).toBe(expected);
});
it('accounts for partially overlapping events', () => {
const expected = -1;
expect(getTimeFrom({ timeStart: 11, dayOffset: 0 }, { timeStart: 10, duration: 2, dayOffset: 0 })).toBe(expected);
expect(
getTimeFrom({ timeStart: 11, dayOffset: 0 as Day }, { timeStart: 10, duration: 2, dayOffset: 0 as Day }),
).toBe(expected);
});
it('accounts for events that are fully contained', () => {
const expected = -6;
expect(getTimeFrom({ timeStart: 10, dayOffset: 0 }, { timeStart: 8, duration: 8, dayOffset: 0 })).toBe(expected);
expect(
getTimeFrom({ timeStart: 10, dayOffset: 0 as Day }, { timeStart: 8, duration: 8, dayOffset: 0 as Day }),
).toBe(expected);
});
it('fully overlapping events are the next day', () => {
const expected = dayInMs - 2 * MILLIS_PER_HOUR;
expect(
getTimeFrom(
{ timeStart: 10 * MILLIS_PER_HOUR, dayOffset: 1 },
{ timeStart: 10 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 },
{ timeStart: 10 * MILLIS_PER_HOUR, dayOffset: 1 as Day },
{ timeStart: 10 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 as Day },
),
).toBe(expected);
});
@@ -36,8 +46,8 @@ describe('getTimeFrom', () => {
const expected = -MILLIS_PER_HOUR; // (previousEnd - currentStart);
expect(
getTimeFrom(
{ timeStart: 22 * MILLIS_PER_HOUR, dayOffset: 0 },
{ timeStart: 20 * MILLIS_PER_HOUR, duration: 3 * MILLIS_PER_HOUR, dayOffset: 0 },
{ timeStart: 22 * MILLIS_PER_HOUR, dayOffset: 0 as Day },
{ timeStart: 20 * MILLIS_PER_HOUR, duration: 3 * MILLIS_PER_HOUR, dayOffset: 0 as Day },
),
).toBe(expected);
});
@@ -46,8 +56,8 @@ describe('getTimeFrom', () => {
const expected = -MILLIS_PER_HOUR; // (previousEnd - currentStart);
expect(
getTimeFrom(
{ timeStart: 1 * MILLIS_PER_HOUR, dayOffset: 1 },
{ timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 },
{ timeStart: 1 * MILLIS_PER_HOUR, dayOffset: 1 as Day },
{ timeStart: 20 * MILLIS_PER_HOUR, duration: 6 * MILLIS_PER_HOUR, dayOffset: 0 as Day },
),
).toBe(expected);
});
@@ -1,9 +1,11 @@
import { Day } from 'ontime-types';
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE } from './conversionUtils';
import { isNewLatest } from './isNewLatest';
describe('isNewLatest', () => {
it('should be true if there is no previous', () => {
const current = { timeStart: 0, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 0, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
const previous = null;
expect(isNewLatest(current, previous)).toBe(true);
});
@@ -12,41 +14,41 @@ describe('isNewLatest', () => {
const current = {
timeStart: 21 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE,
duration: 10 * MILLIS_PER_MINUTE,
dayOffset: 0,
dayOffset: 0 as Day,
};
const previous = { timeStart: 21 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const previous = { timeStart: 21 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(false);
});
it('should be true if it starts when the previous finishes', () => {
const current = { timeStart: 10 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 10 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(true);
});
it('should be true if it starts the same day the previous finishes', () => {
const current = { timeStart: 22 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 22 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(true);
});
it('should be true if it finishes after the previous, accounting for passing midnight', () => {
const current = { timeStart: 1 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 1 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 23 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(true);
});
it('should be true if it the next day', () => {
const current = { timeStart: 8 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 8 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(true);
});
it('should be true if it the next day (2)', () => {
const current = { timeStart: 9 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: 11 * MILLIS_PER_HOUR, dayOffset: 0 };
const current = { timeStart: 9 * MILLIS_PER_HOUR, duration: 2 * MILLIS_PER_HOUR, dayOffset: 1 as Day };
const previous = { timeStart: 9 * MILLIS_PER_HOUR, duration: 11 * MILLIS_PER_HOUR, dayOffset: 0 as Day };
expect(isNewLatest(current, previous)).toBe(true);
});
});
@@ -1,14 +1,14 @@
import { isISO8601, isTimeString } from './isTimeString';
describe('test isTimeString() function', () => {
it('it validates time strings', () => {
it('validates time strings', () => {
const ts = ['2', '2:10', '2:10:22'];
for (const s of ts) {
expect(isTimeString(s)).toBe(true);
}
});
it('it fails overloaded times', () => {
it('fails overloaded times', () => {
const ts = ['70', '89:10', '26:10:22'];
for (const s of ts) {
expect(isTimeString(s)).toBe(false);
@@ -45,7 +45,7 @@ describe('test parseUserTime()', () => {
}
});
describe('#33 separators are parsed according to doc examples ', () => {
describe('#33 separators are parsed according to doc examples', () => {
const ts = [
{ value: '0.1', expect: MILLIS_PER_MINUTE },
{ value: '0 1', expect: MILLIS_PER_MINUTE },
@@ -112,7 +112,7 @@ describe('test parseUserTime()', () => {
{ value: '10AM', expect: 10 * MILLIS_PER_HOUR },
{ value: '10PM', expect: (12 + 10) * MILLIS_PER_HOUR },
{ value: '12am', expect: 0 * MILLIS_PER_HOUR },
{ value: '12am', expect: 0 },
{ value: '12pm', expect: 12 * MILLIS_PER_HOUR },
{ value: '1:10am', expect: 1 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE },
@@ -132,7 +132,7 @@ describe('test parseUserTime()', () => {
{ value: '10:10AM', expect: 10 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE },
{ value: '10:10PM', expect: (12 + 10) * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE },
{ value: '12:10am', expect: 0 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE },
{ value: '12:10am', expect: 10 * MILLIS_PER_MINUTE },
{ value: '12:10pm', expect: 12 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE },
{ value: '1:10:10am', expect: 1 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
@@ -152,7 +152,7 @@ describe('test parseUserTime()', () => {
{ value: '10:10:10AM', expect: 10 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
{ value: '10:10:10PM', expect: (12 + 10) * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
{ value: '12:10:10am', expect: 0 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
{ value: '12:10:10am', expect: 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
{ value: '12:10:10pm', expect: 12 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 10 * MILLIS_PER_SECOND },
];
@@ -1,6 +1,6 @@
import { TimerType } from 'ontime-types';
import { dayInMs, MILLIS_PER_HOUR } from './conversionUtils';
import { MILLIS_PER_HOUR, dayInMs } from './conversionUtils';
import { formatFromMillis, millisToString, removeLeadingZero } from './timeFormatting';
describe('millisToString()', () => {
@@ -1,42 +1,42 @@
import { isColourHex } from './isColourHex';
describe('test isColourHex() function', () => {
it('it validates colour hex strings', () => {
it('validates colour hex strings', () => {
const ts = ['#FFF', '#FFFF', '#FFFFFF', '#FFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it validates colour hex strings', () => {
it('validates colour hex strings', () => {
const ts = ['#F90', '#1234', '#56789A', '#BCDEF012'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it validates colour hex strings', () => {
it('validates colour hex strings', () => {
const ts = ['#f90', '#1234', '#56789a', '#bcdef012'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it fails digits bigger than F', () => {
it('fails digits bigger than F', () => {
const ts = ['#FFG'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
}
});
it('it fails incorect amout of digits', () => {
it('fails incorrect amount of digits', () => {
const ts = ['#F', '#FF', '#FFFFF', '#FFFFFFF', '#FFFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
}
});
it('it fails missing #', () => {
it('fails missing #', () => {
const ts = ['FFF', 'FFFF', 'FFFFFF', 'FFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
@@ -1,5 +1,5 @@
import type { Day, OntimeDelay, OntimeEvent, OntimeGroup, OntimeMilestone } from 'ontime-types';
import { EndAction, SupportedEntry, TimerType, TimeStrategy } from 'ontime-types';
import { EndAction, SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
export const event: Omit<OntimeEvent, 'id' | 'cue'> = {
type: SupportedEntry.Event,
@@ -1,5 +1,5 @@
import type { DatabaseModel } from 'ontime-types';
import { EndAction, OntimeView, SupportedEntry, TimerType, TimeStrategy } from 'ontime-types';
import { EndAction, OntimeView, SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
export const demoDb: DatabaseModel = {
rundowns: {
@@ -4,7 +4,7 @@ import { expect } from 'vitest';
import { validateEndAction, validateTimerType } from './validateEvent.js';
describe('validateEndAction()', () => {
it('recognises a string representation of an action', () => {
it('recognizes a string representation of an action', () => {
const endAction = validateEndAction('load-next');
expect(endAction).toBe(EndAction.LoadNext);
});
@@ -17,7 +17,7 @@ describe('validateEndAction()', () => {
});
describe('validateTimerType()', () => {
it('recognises a string representation of an action', () => {
it('recognizes a string representation of an action', () => {
const timerType = validateTimerType('count-up');
expect(timerType).toBe(TimerType.CountUp);
});
@@ -1,4 +1,4 @@
import { EndAction, TimerType, TimeStrategy } from 'ontime-types';
import { EndAction, TimeStrategy, TimerType } from 'ontime-types';
/**
* Check if a given value is a valid time strategy, returns the fallback otherwise
+24
View File
@@ -0,0 +1,24 @@
{
"extends": "../../tsconfig.common.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"allowUnusedLabels": false,
"removeComments": true,
"preserveConstEnums": true,
"allowJs": true
},
"include": [
"src"
],
"exclude": [
"node_modules",
"src/**/__tests__/**",
"src/**/__test__/**",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*.spec.ts",
"src/**/*.spec.tsx",
]
}
+4 -22
View File
@@ -1,26 +1,8 @@
{
"extends": "../../tsconfig.common.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowUnusedLabels": false,
"removeComments": true,
"preserveConstEnums": true,
"allowJs": true,
"baseUrl": "src"
},
"include": [
"src"
],
"exclude": [
"node_modules",
"src/**/*.test.ts",
"src/**/*.spec.ts",
],
"extends": "./tsconfig.app.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.tests.json"
}
{ "path": "./tsconfig.vitest.json" }
]
}
-20
View File
@@ -1,20 +0,0 @@
{
"extends": "../../tsconfig.tests.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowUnusedLabels": false,
"removeComments": true,
"preserveConstEnums": true,
"allowJs": true,
"baseUrl": "src",
"types": ["vitest/globals"],
"composite": true
},
"include": [
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.mock.ts",
]
}
+13
View File
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"composite": true,
"types": ["vitest/globals"]
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}