Skip to content

Commit

Permalink
Ensure unit tests are triggering the events in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfbyteHeroes committed Dec 4, 2024
1 parent e18e66d commit a052cef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions spec/helper/MockHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ export class PlayerEventHelper {
});
}

fireRestoringContentEvent(): void {
this.fireEvent<PlayerEventBase>({
timestamp: Date.now(),
type: PlayerEvent.RestoringContent,
});
}

fireAdBreakFinishedEvent(): void {
this.fireEvent<AdBreakEvent>({
timestamp: Date.now(),
Expand Down
14 changes: 12 additions & 2 deletions spec/helper/PlayerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,10 @@ export enum PlayerEvent {
* @since v7.5.4
*/
AdBreakStarted = 'adbreakstarted',

/**
* Is fired when the playback of an ad break has ended. Is preceded by a @see {@link AdBreakStarted} event.
* This event is currently only supported for the ad client typ 'ima'.
* Is fired when the playback of an ad break has ended and the main content has been restored. Is preceded by a
* @see {@link AdBreakStarted} event.
* The passed event is of type {@link AdBreakEvent}.
*
* Also accessible via the bitmovin.player.PlayerEvent.AdBreakFinished constant.
Expand All @@ -505,6 +506,15 @@ export enum PlayerEvent {
* @since v7.5.4
*/
AdBreakFinished = 'adbreakfinished',

/**
* Is fired when the playback of an break has finished and the player is about to start restoring the main content.
* Is succeeded by a @see {@link AdBreakStarted} event once the main content has been restored.
*
* @event
* @since v8.192.1
*/
RestoringContent = 'restoringcontent',
/**
* Is fired when the playback of an ad has been finished.
* The passed event is of type {@link AdEvent}.
Expand Down
3 changes: 3 additions & 0 deletions spec/tests/PlayerEvents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,20 @@ describe('player event tests', () => {

it('on adError', () => {
playerEventHelper.fireAdErrorEvent();
playerEventHelper.fireRestoringContentEvent();
playerEventHelper.fireAdBreakFinishedEvent();
expect(MockHelper.latestVideoAnalytics.reportAdBreakEnded).toHaveBeenCalledTimes(1);
});

it('on ad skipped', () => {
playerEventHelper.fireAdSkippedEvent();
playerEventHelper.fireRestoringContentEvent();
playerEventHelper.fireAdBreakFinishedEvent();
expect(MockHelper.latestVideoAnalytics.reportAdBreakEnded).toHaveBeenCalledTimes(1);
});

it('on ad end', () => {
playerEventHelper.fireRestoringContentEvent();
playerEventHelper.fireAdBreakFinishedEvent();
expect(MockHelper.latestVideoAnalytics.reportAdBreakEnded).toHaveBeenCalledTimes(1);
});
Expand Down

0 comments on commit a052cef

Please sign in to comment.