@@ -6,17 +6,21 @@ import { JobContext, ProcessedShowStyleCompound } from '../../jobs/index.js'
66import { mock } from 'jest-mock-extended'
77import { PartAndPieceInstanceActionService } from '../context/services/PartAndPieceInstanceActionService.js'
88import { OnSetAsNextContext } from '../context/index.js'
9+ import { protectString } from '@sofie-automation/corelib/dist/protectedString'
10+ import { PartId , RundownId , SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids'
11+ import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
912
1013describe ( 'Test blueprint api context' , ( ) => {
1114 async function getTestee ( setManually = false ) {
1215 const mockActionService = mock < PartAndPieceInstanceActionService > ( )
16+ const mockPlayoutModel = mock < PlayoutModel > ( )
1317 const context = new OnSetAsNextContext (
1418 {
1519 name : 'fakeContext' ,
1620 identifier : 'action' ,
1721 } ,
1822 mock < JobContext > ( ) ,
19- mock < PlayoutModel > ( ) ,
23+ mockPlayoutModel ,
2024 mock < ProcessedShowStyleCompound > ( ) ,
2125 mock < WatchedPackagesHelper > ( ) ,
2226 mockActionService ,
@@ -26,6 +30,7 @@ describe('Test blueprint api context', () => {
2630 return {
2731 context,
2832 mockActionService,
33+ mockPlayoutModel,
2934 }
3035 }
3136
@@ -100,6 +105,42 @@ describe('Test blueprint api context', () => {
100105 expect ( mockActionService . getPartForPreviousPiece ) . toHaveBeenCalledWith ( { _id : 'pieceId' } )
101106 } )
102107
108+ test ( 'getUpcomingParts' , async ( ) => {
109+ const { context, mockPlayoutModel } = await getTestee ( )
110+
111+ mockPlayoutModel . getAllOrderedParts . mockReturnValue (
112+ mock ( [
113+ {
114+ _id : protectString < PartId > ( 'part1' ) ,
115+ title : 'Part 1' ,
116+ invalid : false ,
117+ floated : false ,
118+ _rank : 1 ,
119+ rundownId : protectString < RundownId > ( 'rundown1' ) ,
120+ externalId : 'ext1' ,
121+ segmentId : protectString < SegmentId > ( 'seg1' ) ,
122+ expectedDurationWithTransition : 1000 ,
123+ userEditOperations : [ ] ,
124+ } as DBPart ,
125+ {
126+ _id : protectString < PartId > ( 'part2' ) ,
127+ title : 'Part 2' ,
128+ invalid : false ,
129+ floated : false ,
130+ _rank : 1 ,
131+ rundownId : protectString < RundownId > ( 'rundown1' ) ,
132+ externalId : 'ext1' ,
133+ segmentId : protectString < SegmentId > ( 'seg1' ) ,
134+ expectedDurationWithTransition : 1000 ,
135+ userEditOperations : [ ] ,
136+ } as unknown as DBPart ,
137+ ] )
138+ )
139+
140+ const parts = await context . getUpcomingParts ( )
141+ expect ( parts . map ( ( i ) => i . title ) ) . toEqual ( [ 'Part 1' , 'Part 2' ] )
142+ } )
143+
103144 test ( 'insertPiece' , async ( ) => {
104145 const { context, mockActionService } = await getTestee ( )
105146
0 commit comments