Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 7, 2022
1 parent 0fe24bc commit d521ea4
Show file tree
Hide file tree
Showing 45 changed files with 159 additions and 215 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"validate:dev-dependencies": "yarn lerna exec --parallel yarn validate:dev-dependencies"
},
"devDependencies": {
"@sofie-automation/code-standard-preset": "~1.0.0",
"@sofie-automation/code-standard-preset": "~1.1.0",
"@types/jest": "^26.0.9",
"@types/node": "^12.20.42",
"@types/request": "^2.48.8",
Expand All @@ -41,6 +41,7 @@
"open-cli": "^6.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.1.0",
"type-fest": "^2.11.1",
"typedoc": "^0.22.10",
"typescript": "~4.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/src/AsyncResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AsyncResolver {
this.onSetTimelineTriggerTime = onSetTimelineTriggerTime
}

public async resolveTimeline(resolveTime: number, timeline: TSRTimeline, limitTime: number, useCache: boolean) {
public resolveTimeline(resolveTime: number, timeline: TSRTimeline, limitTime: number, useCache: boolean) {
const objectsFixed = this._fixNowObjects(timeline, resolveTime)

const resolvedTimeline = Resolver.resolveTimeline(timeline, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,46 @@ export class CasparCG extends EventEmitter {
}

async info() {
return new Promise((resolve) => {
const cmd = new AMCP.InfoCommand()
cmd.response = new Command.AMCPResponse()
cmd.response.code = 200
cmd.response.raw = '200 INFO OK\n1 PAL PLAYING\n2 PAL PLAYING\n3 PAL PLAYING'
cmd.response.data = [
{
channel: 1,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
{
channel: 2,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
{
channel: 3,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
]
resolve(cmd)
})
const cmd = new AMCP.InfoCommand()
cmd.response = new Command.AMCPResponse()
cmd.response.code = 200
cmd.response.raw = '200 INFO OK\n1 PAL PLAYING\n2 PAL PLAYING\n3 PAL PLAYING'
cmd.response.data = [
{
channel: 1,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
{
channel: 2,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
{
channel: 3,
format: 'pal',
channelRate: 50,
frameRate: 25,
interlaced: true,
},
]
return Promise.resolve(cmd)
}
async clear(channel) {
return this.do(new AMCP.ClearCommand({ channel }))
}

async time(channel: number) {
return new Promise((resolve) => {
const cmd = new AMCP.TimeCommand({ channel })
cmd.response = new Command.AMCPResponse()
cmd.response.code = 201
cmd.response.raw = '201 INFO OK\n00:00:00:00'
cmd.response.data = '00:00:00:00'
resolve(cmd)
})
const cmd = new AMCP.TimeCommand({ channel })
cmd.response = new Command.AMCPResponse()
cmd.response.code = 201
cmd.response.raw = '201 INFO OK\n00:00:00:00'
cmd.response.data = '00:00:00:00'
return Promise.resolve(cmd)
}

static get mockDo() {
Expand Down
10 changes: 5 additions & 5 deletions packages/timeline-state-resolver/src/__tests__/conductor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Conductor', () => {
}

const conductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})

Expand Down Expand Up @@ -201,7 +201,7 @@ describe('Conductor', () => {
}

const conductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})

Expand Down Expand Up @@ -330,7 +330,7 @@ describe('Conductor', () => {
return Promise.resolve()
})
const conductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})

Expand Down Expand Up @@ -413,7 +413,7 @@ describe('Conductor', () => {
}

const conductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
conductor.on('error', console.error)
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('Conductor', () => {
}

const conductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})

Expand Down
7 changes: 5 additions & 2 deletions packages/timeline-state-resolver/src/__tests__/mockTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export class MockTime {
getCurrentTime = () => {
return this._now
}
getCurrentTime2 = async (): Promise<number> => {

// eslint-disable-next-line @typescript-eslint/promise-function-async
getCurrentTime2 = (): Promise<number> => {
// Note: this is intentionally not an async, as we are trying to bypass some hackery that threadedClass forces a promise upon us
return this._now as any
}
setNow = (t: number) => {
Expand Down Expand Up @@ -61,7 +64,7 @@ export class MockTime {
}
tick = async () => {
return new Promise((resolve) => {
setImmediate(resolve)
jest.requireActual('timers').setImmediate(resolve)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Rundown', () => {
}

const myConductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
await myConductor.init()
Expand Down
1 change: 0 additions & 1 deletion packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export interface ConductorOptions {
// devices: {
// [deviceName: string]: DeviceOptions
// },
initializeAsClear?: boolean // don't do any initial checks with devices to determine state, instead assume that everything is clear, black and quiet
getCurrentTime?: () => number
autoInit?: boolean
multiThreadedResolver?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Abstract device', () => {
}

const myConductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
await myConductor.init()
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Abstract device', () => {
}

const myConductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
await myConductor.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Atem', () => {
}

const myConductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
await myConductor.init()
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Atem', () => {
}

const myConductor = new Conductor({
initializeAsClear: true,
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
await myConductor.init()
Expand Down
Loading

0 comments on commit d521ea4

Please sign in to comment.