Skip to content

Commit f97453f

Browse files
committed
test: Add test for getUpcomingParts
1 parent 30f0d4f commit f97453f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

packages/job-worker/src/blueprints/__tests__/context-OnTakeContext.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
/* eslint-disable @typescript-eslint/unbound-method */
22
import { IBlueprintMutatablePart, IBlueprintPiece } from '@sofie-automation/blueprints-integration'
3-
import { PlayoutModel } from '../../playout/model/PlayoutModel.js'
43
import { WatchedPackagesHelper } from '../context/watchedPackages.js'
54
import { JobContext, ProcessedShowStyleCompound } from '../../jobs/index.js'
65
import { mock } from 'jest-mock-extended'
76
import { PartAndPieceInstanceActionService } from '../context/services/PartAndPieceInstanceActionService.js'
87
import { OnTakeContext } from '../context/index.js'
8+
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
9+
import { PlayoutModelImpl } from '../../playout/model/implementation/PlayoutModelImpl.js'
910

1011
describe('Test blueprint api context', () => {
1112
async function getTestee() {
13+
const mockPlayoutModel = mock<PlayoutModelImpl>()
1214
const mockActionService = mock<PartAndPieceInstanceActionService>()
1315
const context = new OnTakeContext(
1416
{
1517
name: 'fakeContext',
1618
identifier: 'action',
1719
},
1820
mock<JobContext>(),
19-
mock<PlayoutModel>(),
21+
mockPlayoutModel,
2022
mock<ProcessedShowStyleCompound>(),
2123
mock<WatchedPackagesHelper>(),
2224
mockActionService
@@ -25,6 +27,7 @@ describe('Test blueprint api context', () => {
2527
return {
2628
context,
2729
mockActionService,
30+
mockPlayoutModel,
2831
}
2932
}
3033

@@ -99,6 +102,20 @@ describe('Test blueprint api context', () => {
99102
expect(mockActionService.getPartForPreviousPiece).toHaveBeenCalledWith({ _id: 'pieceId' })
100103
})
101104

105+
test('getUpcomingParts', async () => {
106+
const { context, mockPlayoutModel } = await getTestee()
107+
108+
mockPlayoutModel.getAllOrderedParts.mockReturnValue(
109+
mock([
110+
{ _id: 'part1', title: 'Part 1', invalid: false, floated: false } as unknown as DBPart,
111+
{ _id: 'part2', title: 'Part 2', invalid: false, floated: false } as unknown as DBPart,
112+
])
113+
)
114+
115+
const parts = await context.getUpcomingParts()
116+
expect(parts.map((i) => i.title)).toEqual(['Part 1', 'Part 2'])
117+
})
118+
102119
test('insertPiece', async () => {
103120
const { context, mockActionService } = await getTestee()
104121

0 commit comments

Comments
 (0)