chore: update tests

This commit is contained in:
cv
2023-09-29 22:21:15 +02:00
parent 4498a04a34
commit 34b79e7699
3 changed files with 23 additions and 87 deletions
@@ -1,63 +0,0 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`makeTable() > returns array of arrays with given fields 1`] = `
[
[
"Ontime · Schedule Template",
],
[
"Project Title",
"",
],
[
"Project Description",
"",
],
[
"Public URL",
"",
],
[
"Backstage URL",
"",
],
[],
[
"Time Start",
"Time End",
"Event Title",
"Presenter Name",
"Event Subtitle",
"Is Public? (x)",
"Note",
"Colour",
"End Action",
"Timer Type",
"Skip?",
"user0:test",
],
[
"00:00:00",
"00:00:00",
"test title 1",
"",
"",
"x",
"",
"",
"",
"",
"",
"test",
"test",
"",
"",
"",
"",
"",
"",
"",
"",
],
]
`;
@@ -2,7 +2,6 @@ import { OntimeRundown, SupportedEvent } from 'ontime-types';
import { dayInMs } from '../timeConstants.js';
import { getNextEvent, getPreviousEvent } from './rundownUtils';
import { calculateDuration } from './rundownUtils.js';
describe('getNextEvent()', () => {
it('returns the next event of type event', () => {
@@ -71,25 +70,3 @@ describe('getPreviousEvent()', () => {
expect(previous).toBe(null);
});
});
describe('calculateDuration()', () => {
describe('Given start and end values', () => {
it('is the difference between end and start', () => {
const duration = calculateDuration(10, 20);
expect(duration).toBe(10);
});
});
describe('Handles edge cases', () => {
it('handles events that go over midnight', () => {
const duration = calculateDuration(51, 50);
expect(duration).toBe(dayInMs - 1);
});
it('handles no difference', () => {
const duration1 = calculateDuration(0, 0);
const duration2 = calculateDuration(dayInMs, dayInMs);
expect(duration1).toBe(0);
expect(duration2).toBe(0);
});
});
});
@@ -2,7 +2,7 @@ import { EndAction, TimerType } from 'ontime-types';
import { expect } from 'vitest';
import { dayInMs } from '../timeConstants.js';
import { validateEndAction, validateTimerType, validateTimes } from './validateEvent.js';
import { calculateDuration, validateEndAction, validateTimerType, validateTimes } from './validateEvent.js';
describe('validateEndAction()', () => {
it('recognises a string representation of an action', () => {
@@ -94,3 +94,25 @@ describe('validateTimes()', () => {
expect(duration).toBe(10);
});
});
describe('calculateDuration()', () => {
describe('Given start and end values', () => {
it('is the difference between end and start', () => {
const duration = calculateDuration(10, 20);
expect(duration).toBe(10);
});
});
describe('Handles edge cases', () => {
it('handles events that go over midnight', () => {
const duration = calculateDuration(51, 50);
expect(duration).toBe(dayInMs - 1);
});
it('handles no difference', () => {
const duration1 = calculateDuration(0, 0);
const duration2 = calculateDuration(dayInMs, dayInMs);
expect(duration1).toBe(0);
expect(duration2).toBe(0);
});
});
});