Skip to content

Commit 2c53031

Browse files
committed
chore: add test case for single layer parts with while timings
1 parent 2bee182 commit 2c53031

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

packages/job-worker/src/playout/lookahead/__tests__/findForLayer/lookaheadOffset/lookaheadOffset.test.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ describe('getLookeaheadObjects', () => {
402402

403403
expect(res).toEqual([])
404404
})
405-
406405
test('returns one lookahead object for a single future part', async () => {
407406
getOrderedPartsAfterPlayheadMock.mockReturnValue([
408407
{
@@ -443,7 +442,6 @@ describe('getLookeaheadObjects', () => {
443442
file: 'AMB',
444443
})
445444
})
446-
447445
test('respects lookaheadMaxSearchDistance', async () => {
448446
findLargestLookaheadDistanceMock.mockReturnValue(10)
449447
getOrderedPartsAfterPlayheadMock.mockReturnValue([
@@ -477,7 +475,6 @@ describe('getLookeaheadObjects', () => {
477475
expect(res).toHaveLength(1)
478476
expect(res[0].partInstanceId).toContain('p1')
479477
})
480-
481478
test('applies nextTimeOffset to lookahead objects in future part', async () => {
482479
playoutModel = {
483480
...playoutModel,
@@ -498,7 +495,6 @@ describe('getLookeaheadObjects', () => {
498495
expect(res).toHaveLength(1)
499496
expect(res[0].lookaheadOffset).toBe(5000)
500497
})
501-
502498
test('applies nextTimeOffset to lookahead objects in nextPart with no offset on next part', async () => {
503499
playoutModel = {
504500
...playoutModel,
@@ -543,7 +539,6 @@ describe('getLookeaheadObjects', () => {
543539
expect(res[0].lookaheadOffset).toBe(5000)
544540
expect(res[1].lookaheadOffset).toBe(undefined)
545541
})
546-
547542
test('Multi layer part produces lookahead objects for all layers with the correct offsets', async () => {
548543
playoutModel = {
549544
...playoutModel,
@@ -642,4 +637,36 @@ describe('getLookeaheadObjects', () => {
642637
expect(res.map((o) => o.layer)).toEqual(['layer1_lookahead', 'layer1_lookahead'])
643638
expect(res.map((o) => o.lookaheadOffset)).toEqual([500, undefined])
644639
})
640+
test('Single layer part produces lookahead objects with while enable values with the correct offsets', async () => {
641+
playoutModel = {
642+
...playoutModel,
643+
playlist: {
644+
...playoutModel.playlist,
645+
nextTimeOffset: 1000,
646+
},
647+
} as PlayoutModel
648+
getOrderedPartsAfterPlayheadMock.mockReturnValue([
649+
{ ...lookaheadOffsetTestConstants.singleLayerPartWhile, classesForNext: [] } as any,
650+
])
651+
652+
context.directCollections.Pieces.findFetch = jest
653+
.fn()
654+
.mockResolvedValue(lookaheadOffsetTestConstants.singleLayerPartWhile.pieces)
655+
656+
const res = await getLookeaheadObjects(context, playoutModel, {
657+
next: {
658+
...lookaheadOffsetTestConstants.singleLayerPartWhile,
659+
pieceInstances: lookaheadOffsetTestConstants.singleLayerPartWhile.pieces.map((piece) =>
660+
wrapPieceToInstance(
661+
piece as any,
662+
'pA1' as any,
663+
lookaheadOffsetTestConstants.singleLayerPartWhile.partInstance._id
664+
)
665+
),
666+
},
667+
} as any)
668+
expect(res).toHaveLength(2)
669+
expect(res.map((o) => o.layer)).toEqual(['layer1_lookahead', 'layer1_lookahead'])
670+
expect(res.map((o) => o.lookaheadOffset)).toEqual([500, undefined])
671+
})
645672
})

0 commit comments

Comments
 (0)