Skip to content

Commit

Permalink
fix: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 7, 2022
1 parent d521ea4 commit 031bbd1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Sisyfos', () => {
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await myConductor.init() // we cannot do an await, because setTimeout will never call without jest moving on.
await myConductor.addDevice('mySisyfos', {
type: DeviceType.SISYFOS,
Expand All @@ -85,13 +84,15 @@ describe('Sisyfos', () => {
},
commandReceiver: commandReceiver0,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await mockTime.advanceTimeToTicks(10100)

const deviceContainer = myConductor.getDevice('mySisyfos')
const device = deviceContainer!.device as ThreadedClass<SisyfosMessageDevice>

// Check that no commands has been scheduled:
expect(await device.queue).toHaveLength(0)
commandReceiver0.mockClear()

myConductor.setTimelineAndMappings([
{
Expand Down Expand Up @@ -194,8 +195,10 @@ describe('Sisyfos', () => {
},
] as TSRTimeline)

expect(commandReceiver0.mock.calls.length).toEqual(0)
await mockTime.advanceTimeTicks(100) // now-ish
expect(commandReceiver0.mock.calls.length).toEqual(1)

// set pgm
expect(getMockCall(commandReceiver0, 0, 1)).toMatchObject({
type: 'togglePgm',
Expand Down Expand Up @@ -291,7 +294,6 @@ describe('Sisyfos', () => {
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await myConductor.init() // we cannot do an await, because setTimeout will never call without jest moving on.
await myConductor.addDevice('mySisyfos', {
type: DeviceType.SISYFOS,
Expand All @@ -301,13 +303,15 @@ describe('Sisyfos', () => {
},
commandReceiver: commandReceiver0,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await mockTime.advanceTimeToTicks(10100)

const deviceContainer = myConductor.getDevice('mySisyfos')
const device = deviceContainer!.device as ThreadedClass<SisyfosMessageDevice>

// Check that no commands has been scheduled:
expect(await device.queue).toHaveLength(0)
commandReceiver0.mockClear()

myConductor.setTimelineAndMappings([
{
Expand Down Expand Up @@ -508,7 +512,6 @@ describe('Sisyfos', () => {
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await myConductor.init() // we cannot do an await, because setTimeout will never call without jest moving on.
await myConductor.addDevice('mySisyfos', {
type: DeviceType.SISYFOS,
Expand All @@ -518,13 +521,15 @@ describe('Sisyfos', () => {
},
commandReceiver: commandReceiver0,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await mockTime.advanceTimeToTicks(10100)

const deviceContainer = myConductor.getDevice('mySisyfos')
const device = deviceContainer!.device as ThreadedClass<SisyfosMessageDevice>

// Check that no commands has been scheduled:
expect(await device.queue).toHaveLength(0)
commandReceiver0.mockClear()

myConductor.setTimelineAndMappings([
{
Expand Down Expand Up @@ -637,7 +642,6 @@ describe('Sisyfos', () => {
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await myConductor.init() // we cannot do an await, because setTimeout will never call without jest moving on.
await myConductor.addDevice('mySisyfos', {
type: DeviceType.SISYFOS,
Expand All @@ -647,13 +651,15 @@ describe('Sisyfos', () => {
},
commandReceiver: commandReceiver0,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await mockTime.advanceTimeToTicks(10100)

const deviceContainer = myConductor.getDevice('mySisyfos')
const device = deviceContainer!.device as ThreadedClass<SisyfosMessageDevice>

// Check that no commands has been scheduled:
expect(await device.queue).toHaveLength(0)
commandReceiver0.mockClear()

myConductor.setTimelineAndMappings([
{
Expand Down Expand Up @@ -844,7 +850,6 @@ describe('Sisyfos', () => {
multiThreadedResolver: false,
getCurrentTime: mockTime.getCurrentTime,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await myConductor.init() // we cannot do an await, because setTimeout will never call without jest moving on.
await myConductor.addDevice('mySisyfos', {
type: DeviceType.SISYFOS,
Expand All @@ -854,13 +859,15 @@ describe('Sisyfos', () => {
},
commandReceiver: commandReceiver0,
})
myConductor.setTimelineAndMappings([], myChannelMapping)
await mockTime.advanceTimeToTicks(10100)

const deviceContainer = myConductor.getDevice('mySisyfos')
const device = deviceContainer!.device as ThreadedClass<SisyfosMessageDevice>

// Check that no commands has been scheduled:
expect(await device.queue).toHaveLength(0)
commandReceiver0.mockClear()

myConductor.setTimelineAndMappings([
{
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/src/devices/lawo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class LawoDevice extends DeviceWithState<LawoState, DeviceOptionsLawoInte
if (deviceOptions.commandReceiver) {
this._commandReceiver = deviceOptions.commandReceiver
} else {
this._defaultCommandReceiver.bind(this)
this._commandReceiver = this._defaultCommandReceiver.bind(this)
}
if (deviceOptions.options.setValueFn) {
this._setValueFn = deviceOptions.options.setValueFn
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/src/devices/obs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class OBSDevice extends DeviceWithState<OBSState, DeviceOptionsOBSInterna
if (deviceOptions.commandReceiver) {
this._commandReceiver = deviceOptions.commandReceiver
} else {
this._defaultCommandReceiver.bind(this)
this._commandReceiver = this._defaultCommandReceiver.bind(this)
}
}
this._doOnTime = new DoOnTime(
Expand Down
6 changes: 2 additions & 4 deletions packages/timeline-state-resolver/src/devices/osc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ export class OSCMessageDevice extends DeviceWithState<OSCDeviceState, DeviceOpti
if (deviceOptions.commandReceiver) {
this._commandReceiver = deviceOptions.commandReceiver
} else {
this._defaultCommandReceiver.bind(this)
this._commandReceiver = this._defaultCommandReceiver.bind(this)
}
if (deviceOptions.oscSender) {
this._oscSender = deviceOptions.oscSender
} else {
this._oscSender = async (...args) => {
return this._defaultOscSender(...args)
}
this._oscSender = this._defaultOscSender.bind(this)
}
}
this._doOnTime = new DoOnTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class PanasonicPtzDevice extends DeviceWithState<PanasonicPtzState, Devic
if (deviceOptions.commandReceiver) {
this._commandReceiver = deviceOptions.commandReceiver
} else {
this._defaultCommandReceiver.bind(this)
this._commandReceiver = this._defaultCommandReceiver.bind(this)
}
}
this._doOnTime = new DoOnTime(
Expand Down

0 comments on commit 031bbd1

Please sign in to comment.