@@ -2,7 +2,7 @@ import { resolveDownstreamKeyerState } from '../downstreamKeyer'
22import { Commands , VideoState } from 'atem-connection'
33import * as Defaults from '../../defaults'
44import { jsonClone } from '../../util'
5- import { DiffDownstreamKeyer } from '../../diff'
5+ import { DiffDownstreamKeyer , SectionsToDiff } from '../../diff'
66
77function setupDSK ( props ?: Partial < VideoState . DSK . DownstreamKeyer > ) : Required < VideoState . DSK . DownstreamKeyer > {
88 return jsonClone ( {
@@ -19,15 +19,17 @@ function setupDSK(props?: Partial<VideoState.DSK.DownstreamKeyer>): Required<Vid
1919const DSK1 = [ setupDSK ( ) , setupDSK ( ) ]
2020const DSK2 = [ setupDSK ( ) , setupDSK ( ) ]
2121
22- const fullDiff : Required < DiffDownstreamKeyer > = {
23- sources : true ,
24- onAir : true ,
25- properties : true ,
26- mask : true ,
22+ const fullDiff : SectionsToDiff [ 'video' ] & { downstreamKeyers : Required < DiffDownstreamKeyer > } = {
23+ downstreamKeyers : {
24+ sources : true ,
25+ onAir : true ,
26+ properties : true ,
27+ mask : true ,
28+ } ,
2729}
2830
2931test ( 'Unit: Downstream keyer: same state gives no commands' , function ( ) {
30- const commands = resolveDownstreamKeyerState ( DSK1 , DSK1 , fullDiff )
32+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK1 , fullDiff )
3133 expect ( commands ) . toHaveLength ( 0 )
3234} )
3335
@@ -38,7 +40,7 @@ test('Unit: Downstream keyer: auto and onAir commands', function () {
3840 isAuto : true ,
3941 }
4042
41- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
43+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
4244 expect ( commands ) . toHaveLength ( 2 )
4345
4446 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyOnAirCommand
@@ -63,7 +65,7 @@ test('Unit: Downstream keyer: sources', function () {
6365 DSK2 [ 0 ] . sources . fillSource = 1
6466 DSK2 [ 1 ] . sources . cutSource = 2
6567
66- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
68+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
6769 expect ( commands ) . toHaveLength ( 2 )
6870
6971 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyFillSourceCommand
@@ -86,7 +88,7 @@ test('Unit: Downstream keyer: sources', function () {
8688
8789test ( 'Unit: Downstream keyer: rate' , function ( ) {
8890 DSK2 [ 0 ] . properties . rate = 50
89- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
91+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
9092 expect ( commands ) . toHaveLength ( 1 )
9193
9294 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyRateCommand
@@ -100,7 +102,7 @@ test('Unit: Downstream keyer: rate', function () {
100102
101103test ( 'Unit: Downstream keyer: tie' , function ( ) {
102104 DSK2 [ 0 ] . properties . tie = true
103- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
105+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
104106 expect ( commands ) . toHaveLength ( 1 )
105107
106108 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyTieCommand
@@ -117,7 +119,7 @@ test('Unit: Downstream keyer: properties', function () {
117119 DSK2 [ 0 ] . properties . clip = 500
118120 DSK2 [ 0 ] . properties . gain = 50
119121 DSK2 [ 0 ] . properties . invert = true
120- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
122+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
121123 expect ( commands ) . toHaveLength ( 1 )
122124
123125 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyGeneralCommand
@@ -143,7 +145,7 @@ test('Unit: Downstream keyer: mask', function () {
143145 left : 3 ,
144146 right : 4 ,
145147 }
146- const commands = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
148+ const { commands } = resolveDownstreamKeyerState ( DSK1 , DSK2 , fullDiff )
147149 expect ( commands ) . toHaveLength ( 1 )
148150
149151 const firstCommand = commands [ 0 ] as Commands . DownstreamKeyMaskCommand
@@ -164,3 +166,14 @@ test('Unit: Downstream keyer: mask', function () {
164166 right : 0 ,
165167 }
166168} )
169+
170+ test ( 'Unit: Downstream keyer: onAir with tie returns doTransition' , function ( ) {
171+ DSK2 [ 0 ] . properties . tie = true
172+ DSK2 [ 0 ] . onAir = true
173+ const { commands, doTransition } = resolveDownstreamKeyerState ( DSK1 , DSK2 , {
174+ ...fullDiff ,
175+ mixEffects : { programPreview : true } ,
176+ } )
177+ expect ( doTransition ) . toBe ( true )
178+ expect ( commands . filter ( ( c ) => c . constructor . name === 'DownstreamKeyOnAirCommand' ) ) . toHaveLength ( 0 )
179+ } )
0 commit comments