mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
657cc22b44
* feat: parse cue * refactor: get delay from backend * feat: add cue to UI * refactor: remove deprecated delay logic * refactor: extract studio clock specific logic * refactor: extract utilities * refactor: fix issue with missing key * style: prevent cue overflow * style: prevent whitespace wrap * feat: add support for cues in integrations
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { parseExcelDate } from '../time.js';
|
|
|
|
describe('parseExcelDate', () => {
|
|
describe.todo('parses a valid date string as expected from excel', () => {
|
|
const testCases = [
|
|
{
|
|
fromExcel: '1899-12-30T00:00:00.000Z',
|
|
expected: 3600000,
|
|
},
|
|
{
|
|
fromExcel: '1899-12-30T00:10:00.000Z',
|
|
expected: 4200000,
|
|
},
|
|
{
|
|
fromExcel: '1899-12-30T01:00:00.000Z',
|
|
expected: 7200000,
|
|
},
|
|
{
|
|
fromExcel: '1899-12-30T07:00:00.000Z',
|
|
expected: 28800000,
|
|
},
|
|
{
|
|
fromExcel: '1899-12-30T08:00:10.000Z',
|
|
expected: 32410000,
|
|
},
|
|
{
|
|
fromExcel: '1899-12-30T08:30:00.000Z',
|
|
expected: 34200000,
|
|
},
|
|
];
|
|
|
|
for (const scenario of testCases) {
|
|
it(`handles ${scenario.fromExcel}`, () => {
|
|
expect(parseExcelDate(scenario.fromExcel)).toBe(scenario.expected);
|
|
});
|
|
}
|
|
});
|
|
|
|
describe('parses a time string that passes validation', () => {
|
|
const validFields = ['10:00:00', '10:00'];
|
|
validFields.forEach((field) => {
|
|
it(`handles ${field}`, () => {
|
|
const millis = parseExcelDate(field);
|
|
expect(millis).not.toBe(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('returns 0 on other strings', () => {
|
|
const invalidFields = ['10', 'test', ''];
|
|
invalidFields.forEach((field) => {
|
|
it(`handles ${field}`, () => {
|
|
const millis = parseExcelDate(field);
|
|
expect(millis).toBe(0);
|
|
});
|
|
});
|
|
});
|
|
});
|