Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Oct 11, 2024
1 parent 8246f88 commit b468cf4
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 60 deletions.
2 changes: 1 addition & 1 deletion apps/app/jest.config.js → apps/app/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line n/no-unpublished-require
const base = require('../../jest.config.base')
const base = require('../../jest.config.base.cjs')
const packageJson = require('./package')

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react:dev": "vite",
"electron:dev": "nodemon",
"dev": "concurrently --kill-others \"yarn react:dev\" \"yarn electron:dev\"",
"test": "jest"
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js"
},
"repository": {
"type": "git",
Expand Down
52 changes: 26 additions & 26 deletions apps/app/src/ipc/IPCAPI.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { PartialDeep } from 'type-fest'
import { BridgeStatus } from '../models/project/Bridge.js'
import { Project, SerializableLedger } from '../models/project/Project.js'
import { ResourceAny, ResourceId, MetadataAny, SerializedProtectedMap, TSRDeviceId } from '@shared/models'
import { Rundown } from '../models/rundown/Rundown.js'
import { TimelineObj } from '../models/rundown/TimelineObj.js'
import { Part } from '../models/rundown/Part.js'
import { Group } from '../models/rundown/Group.js'
import { AppData } from '../models/App/AppData.js'
import { PeripheralArea, PeripheralStatus } from '../models/project/Peripheral.js'
import { ActiveTrigger, ActiveTriggers, ApplicationTrigger, RundownTrigger } from '../models/rundown/Trigger.js'
import { BridgeId, LogLevel, PeripheralId } from '@shared/api'
import { MoveTarget } from '../lib/util.js'
import { CurrentSelectionAny } from '../lib/GUI.js'
import { ActiveAnalog } from '../models/rundown/Analog.js'
import { AnalogInput } from '../models/project/AnalogInput.js'
import { ValidatorCache } from 'graphics-data-definition'
import { BridgePeripheralId } from '@shared/lib'
import { DefiningArea } from '../lib/triggers/keyDisplay/keyDisplay.js'
import { type EverythingService } from '../electron/EverythingService.js'
import { type PartService } from '../electron/api/PartService.js'
import { type ProjectService } from '../electron/api/ProjectService.js'
import { type ReportingService } from '../electron/api/ReportingService.js'
import { type RundownService } from '../electron/api/RundownService.js'
import { type GroupService } from '../electron/api/GroupService.js'
import { type SpecialLedgers } from '../models/project/Project.js'
import type { PartialDeep } from 'type-fest'
import type { BridgeStatus } from '../models/project/Bridge.js'
import type { Project, SerializableLedger } from '../models/project/Project.js'
import type { ResourceAny, ResourceId, MetadataAny, SerializedProtectedMap, TSRDeviceId } from '@shared/models'
import type { Rundown } from '../models/rundown/Rundown.js'
import type { TimelineObj } from '../models/rundown/TimelineObj.js'
import type { Part } from '../models/rundown/Part.js'
import type { Group } from '../models/rundown/Group.js'
import type { AppData } from '../models/App/AppData.js'
import type { PeripheralArea, PeripheralStatus } from '../models/project/Peripheral.js'
import type { ActiveTrigger, ActiveTriggers, ApplicationTrigger, RundownTrigger } from '../models/rundown/Trigger.js'
import type { BridgeId, LogLevel, PeripheralId } from '@shared/api'
import type { MoveTarget } from '../lib/util.js'
import type { CurrentSelectionAny } from '../lib/GUI.js'
import type { ActiveAnalog } from '../models/rundown/Analog.js'
import type { AnalogInput } from '../models/project/AnalogInput.js'
import type { ValidatorCache } from 'graphics-data-definition'
import type { BridgePeripheralId } from '@shared/lib'
import type { DefiningArea } from '../lib/triggers/keyDisplay/keyDisplay.js'
import type { EverythingService } from '../electron/EverythingService.js'
import type { PartService } from '../electron/api/PartService.js'
import type { ProjectService } from '../electron/api/ProjectService.js'
import type { ReportingService } from '../electron/api/ReportingService.js'
import type { RundownService } from '../electron/api/RundownService.js'
import type { GroupService } from '../electron/api/GroupService.js'
import type { SpecialLedgers } from '../models/project/Project.js'

export enum ServiceName {
GROUPS = 'groups',
Expand Down
21 changes: 14 additions & 7 deletions apps/app/src/ipc/__tests__/IPCAPI.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { ClientMethods, ServiceName, ServiceTypes } from '../IPCAPI'
import { jest } from '@jest/globals'

import { EverythingService } from '../../electron/EverythingService'
import { PartService } from '../../electron/api/PartService'
import { ProjectService } from '../../electron/api/ProjectService'
import { ReportingService } from '../../electron/api/ReportingService'
import { RundownService } from '../../electron/api/RundownService'
import { GroupService } from '../../electron/api/GroupService'
// Mock electron as it doesn't provide sensible exports during tests
jest.unstable_mockModule('electron', () => ({
dialog: null,
}))

// Delay import after the mock ahs been setup
const { EverythingService } = await import('../../electron/EverythingService')
const { PartService } = await import('../../electron/api/PartService')
const { ProjectService } = await import('../../electron/api/ProjectService')
const { ReportingService } = await import('../../electron/api/ReportingService')
const { RundownService } = await import('../../electron/api/RundownService')
const { GroupService } = await import('../../electron/api/GroupService')

describe('ClientMethods', () => {
const services: ServiceTypes = {
Expand Down Expand Up @@ -47,7 +54,7 @@ describe('ClientMethods', () => {

for (const method of clientMethods) {
if (typeof serviceMethods[method] !== 'function') {
nonexistantMethods.push(`${serviceType}.${method}`)
nonexistantMethods.push(`${serviceType}.${String(method)}`)
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions apps/app/tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": ["src/**/*"],
"exclude": ["dist"]
}
8 changes: 7 additions & 1 deletion jest.config.base.js → jest.config.base.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
roots: ['<rootDir>/src'],
projects: ['<rootDir>'],
preset: 'ts-jest',
moduleFileExtensions: ['js', 'ts'],
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.(ts|tsx)$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
tsconfig: 'tsconfig.jest.json',
useESM: true,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"rimraf": "^6.0.1",
"shelljs": "^0.8.5",
"ts-jest": "^29.2.5",
"typescript": "~5.1"
"typescript": "~5.6.3"
},
"lint-staged": {
"*.{css,json,md,scss}": [
Expand Down
26 changes: 3 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14159,7 +14159,7 @@ asn1@evs-broadcast/node-asn1:
rimraf: "npm:^6.0.1"
shelljs: "npm:^0.8.5"
ts-jest: "npm:^29.2.5"
typescript: "npm:~5.1"
typescript: "npm:~5.6.3"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -14948,7 +14948,7 @@ asn1@evs-broadcast/node-asn1:
languageName: node
linkType: hard

"typescript@npm:>=3 < 6, typescript@npm:^5.3.3":
"typescript@npm:>=3 < 6, typescript@npm:^5.3.3, typescript@npm:~5.6.3":
version: 5.6.3
resolution: "typescript@npm:5.6.3"
bin:
Expand All @@ -14958,17 +14958,7 @@ asn1@evs-broadcast/node-asn1:
languageName: node
linkType: hard

"typescript@npm:~5.1":
version: 5.1.6
resolution: "typescript@npm:5.1.6"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/45ac28e2df8365fd28dac42f5d62edfe69a7203d5ec646732cadc04065331f34f9078f81f150fde42ed9754eed6fa3b06a8f3523c40b821e557b727f1992e025
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A>=3 < 6#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A^5.3.3#optional!builtin<compat/typescript>":
"typescript@patch:typescript@npm%3A>=3 < 6#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A^5.3.3#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A~5.6.3#optional!builtin<compat/typescript>":
version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=8c6c40"
bin:
Expand All @@ -14978,16 +14968,6 @@ asn1@evs-broadcast/node-asn1:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A~5.1#optional!builtin<compat/typescript>":
version: 5.1.6
resolution: "typescript@patch:typescript@npm%3A5.1.6#optional!builtin<compat/typescript>::version=5.1.6&hash=5da071"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/c2bded58ab897a8341fdbb0c1d92ea2362f498cfffebdc8a529d03e15ea2454142dfbf122dabbd9a5cb79b7123790d27def16e11844887d20636226773ed329a
languageName: node
linkType: hard

"uglify-js@npm:^3.1.4":
version: 3.14.5
resolution: "uglify-js@npm:3.14.5"
Expand Down

0 comments on commit b468cf4

Please sign in to comment.