mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
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:
@@ -1,41 +1,37 @@
|
||||
import { TriggerDTO, TimerLifeCycle, AutomationDTO, Automation, ProjectRundowns } from 'ontime-types';
|
||||
import { Automation, AutomationDTO, ProjectRundowns, TimerLifeCycle, TriggerDTO } from 'ontime-types';
|
||||
|
||||
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
|
||||
|
||||
import {
|
||||
addTrigger,
|
||||
addAutomation,
|
||||
addTrigger,
|
||||
deleteAll,
|
||||
deleteAllTriggers,
|
||||
deleteTrigger,
|
||||
deleteAutomation,
|
||||
editTrigger,
|
||||
deleteTrigger,
|
||||
editAutomation,
|
||||
editTrigger,
|
||||
getAutomationTriggers,
|
||||
getAutomations,
|
||||
} from '../automation.dao.js';
|
||||
import { makeHTTPAction, makeOSCAction } from './testUtils.js';
|
||||
|
||||
import { makeOSCAction, makeHTTPAction } from './testUtils.js';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
|
||||
// Create a small mock store
|
||||
let automations = {
|
||||
enabledAutomations: true,
|
||||
enabledOscIn: true,
|
||||
oscPortIn: 8888,
|
||||
triggers: [],
|
||||
automations: {},
|
||||
};
|
||||
return {
|
||||
getDataProvider: vi.fn().mockImplementation(() => {
|
||||
return {
|
||||
getAutomation: vi.fn().mockImplementation(() => automations),
|
||||
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
|
||||
// Create a small mock store
|
||||
let automations = {
|
||||
enabledAutomations: true,
|
||||
enabledOscIn: true,
|
||||
oscPortIn: 8888,
|
||||
triggers: [],
|
||||
automations: {},
|
||||
};
|
||||
return {
|
||||
getDataProvider: vi.fn().mockImplementation(() => {
|
||||
return {
|
||||
getAutomation: vi.fn().mockImplementation(() => automations),
|
||||
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
@@ -141,7 +137,7 @@ describe('addAutomation()', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('editAutomation()', async () => {
|
||||
describe('editAutomation()', () => {
|
||||
// saving the ID of the added automation
|
||||
let firstAutomation: Automation;
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -1,35 +1,31 @@
|
||||
import { PlayableEvent, TimerLifeCycle } from 'ontime-types';
|
||||
|
||||
import { makeRuntimeStoreData } from '../../../stores/__mocks__/runtimeStore.mocks.js';
|
||||
|
||||
import { deleteAllTriggers, addTrigger, addAutomation } from '../automation.dao.js';
|
||||
import { testConditions, triggerAutomations } from '../automation.service.js';
|
||||
import * as oscClient from '../clients/osc.client.js';
|
||||
import * as httpClient from '../clients/http.client.js';
|
||||
|
||||
import { makeOSCAction, makeHTTPAction } from './testUtils.js';
|
||||
import { RuntimeState } from '../../../stores/runtimeState.js';
|
||||
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
|
||||
import { addAutomation, addTrigger, deleteAllTriggers } from '../automation.dao.js';
|
||||
import { testConditions, triggerAutomations } from '../automation.service.js';
|
||||
import * as httpClient from '../clients/http.client.js';
|
||||
import * as oscClient from '../clients/osc.client.js';
|
||||
import { makeHTTPAction, makeOSCAction } from './testUtils.js';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
|
||||
// Create a small mock store
|
||||
let automations = {
|
||||
enabledAutomations: true,
|
||||
enabledOscIn: true,
|
||||
oscPortIn: 8888,
|
||||
triggers: [],
|
||||
automations: {},
|
||||
};
|
||||
return {
|
||||
getDataProvider: vi.fn().mockImplementation(() => {
|
||||
return {
|
||||
getAutomation: vi.fn().mockImplementation(() => automations),
|
||||
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
|
||||
// Create a small mock store
|
||||
let automations = {
|
||||
enabledAutomations: true,
|
||||
enabledOscIn: true,
|
||||
oscPortIn: 8888,
|
||||
triggers: [],
|
||||
automations: {},
|
||||
};
|
||||
return {
|
||||
getDataProvider: vi.fn().mockImplementation(() => {
|
||||
return {
|
||||
getAutomation: vi.fn().mockImplementation(() => automations),
|
||||
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
@@ -41,7 +37,7 @@ describe('triggerAction()', () => {
|
||||
let httpSpy = vi.spyOn(httpClient, 'emitHTTP');
|
||||
|
||||
beforeAll(() => {
|
||||
vi.mock('../../../stores/EventStore.js', () => {
|
||||
vi.doMock('../../../stores/EventStore.js', () => {
|
||||
// Create a small mock store
|
||||
return {
|
||||
eventStore: {
|
||||
@@ -49,11 +45,11 @@ describe('triggerAction()', () => {
|
||||
},
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
oscSpy = vi.spyOn(oscClient, 'emitOSC').mockImplementation(() => { });
|
||||
httpSpy = vi.spyOn(httpClient, 'emitHTTP').mockImplementation(() => { });
|
||||
oscSpy = vi.spyOn(oscClient, 'emitOSC').mockImplementation(() => {});
|
||||
httpSpy = vi.spyOn(httpClient, 'emitHTTP').mockImplementation(() => {});
|
||||
|
||||
await deleteAllTriggers();
|
||||
const oscAutomation = await addAutomation({
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ProjectRundowns, TimerLifeCycle } from 'ontime-types';
|
||||
|
||||
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
|
||||
|
||||
import { isAutomationUsed, parseTemplateNested, stringToOSCArgs } from '../automation.utils.js';
|
||||
|
||||
describe('parseTemplateNested()', () => {
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('parseOutput', () => {
|
||||
address: '/test',
|
||||
args: 'test',
|
||||
};
|
||||
expect(() => parseOutput(payload)).toThrow();
|
||||
expect(() => parseOutput(payload)).toThrow('Unexpected payload type:');
|
||||
});
|
||||
});
|
||||
describe('handles HTTP outputs', () => {
|
||||
@@ -39,7 +39,7 @@ describe('parseOutput', () => {
|
||||
const payload = {
|
||||
type: 'http',
|
||||
};
|
||||
expect(() => parseOutput(payload)).toThrow();
|
||||
expect(() => parseOutput(payload)).toThrow('Unexpected payload type:');
|
||||
});
|
||||
});
|
||||
describe('handles Ontime outputs', () => {
|
||||
@@ -79,7 +79,7 @@ describe('parseOutput', () => {
|
||||
type: 'ontime',
|
||||
action: 'not-exist',
|
||||
};
|
||||
expect(() => parseOutput(payload)).toThrow();
|
||||
expect(() => parseOutput(payload)).toThrow('Invalid Ontime action');
|
||||
});
|
||||
|
||||
it('parses message-set', () => {
|
||||
@@ -122,45 +122,46 @@ describe('parseOutput', () => {
|
||||
text: 123,
|
||||
visible: '',
|
||||
}),
|
||||
).toThrow();
|
||||
).toThrow('Unexpected payload type:');
|
||||
});
|
||||
|
||||
it('parses message-secondary', () => {});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'test',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: null,
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: '',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: null,
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
it('parses message-secondary', () => {
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'test',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: null,
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: '',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: null,
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'aux1',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'aux1',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'aux1',
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
});
|
||||
expect(
|
||||
parseOutput({
|
||||
type: 'ontime',
|
||||
action: 'message-secondary',
|
||||
secondarySource: 'secondary',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'secondary',
|
||||
}),
|
||||
).toMatchObject({
|
||||
secondarySource: 'secondary',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OSCOutput, HTTPOutput } from 'ontime-types';
|
||||
import { HTTPOutput, OSCOutput } from 'ontime-types';
|
||||
|
||||
export function makeOSCAction(action?: Partial<OSCOutput>): OSCOutput {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user