From 34b79e769974307340e7ee779c62fb9ba10ec1b6 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Fri, 29 Sep 2023 22:21:15 +0200 Subject: [PATCH] chore: update tests --- .../__snapshots__/utils.test.js.snap | 63 ------------------- .../src/rundown-utils/rundownUtils.test.ts | 23 ------- .../src/validate-events/validateEvent.test.ts | 24 ++++++- 3 files changed, 23 insertions(+), 87 deletions(-) delete mode 100644 apps/client/src/features/cuesheet/__tests__/__snapshots__/utils.test.js.snap diff --git a/apps/client/src/features/cuesheet/__tests__/__snapshots__/utils.test.js.snap b/apps/client/src/features/cuesheet/__tests__/__snapshots__/utils.test.js.snap deleted file mode 100644 index b5716d433..000000000 --- a/apps/client/src/features/cuesheet/__tests__/__snapshots__/utils.test.js.snap +++ /dev/null @@ -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", - "", - "", - "", - "", - "", - "", - "", - "", - ], -] -`; diff --git a/packages/utils/src/rundown-utils/rundownUtils.test.ts b/packages/utils/src/rundown-utils/rundownUtils.test.ts index 677fccf5e..874eac7ea 100644 --- a/packages/utils/src/rundown-utils/rundownUtils.test.ts +++ b/packages/utils/src/rundown-utils/rundownUtils.test.ts @@ -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); - }); - }); -}); diff --git a/packages/utils/src/validate-events/validateEvent.test.ts b/packages/utils/src/validate-events/validateEvent.test.ts index 071b4cd91..76eca2c99 100644 --- a/packages/utils/src/validate-events/validateEvent.test.ts +++ b/packages/utils/src/validate-events/validateEvent.test.ts @@ -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); + }); + }); +});