From 80550ac8b5c45548f1e028df02e94fc62450afc1 Mon Sep 17 00:00:00 2001 From: Mo Mustafa Date: Thu, 5 Sep 2024 08:05:29 -0700 Subject: [PATCH] fix:accept CurrentPlayheadPosition with 0 value --- src/session.ts | 3 +-- test/session.test.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/session.ts b/src/session.ts index cac0412..a1f0ba5 100644 --- a/src/session.ts +++ b/src/session.ts @@ -160,8 +160,7 @@ export class MediaSession { options: Options = {}, ): MediaEvent { // Set event option based on options or current state - this.currentPlayheadPosition = - options?.currentPlayheadPosition || this.currentPlayheadPosition; + this.currentPlayheadPosition = options?.currentPlayheadPosition; // Merge Session Attributes with any other optional Event Attributes. // Event-Level Custom Attributes will override Session Custom Attributes if there is a collison. diff --git a/test/session.test.ts b/test/session.test.ts index 06fd7d9..721cec4 100644 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -746,6 +746,24 @@ describe('MediaSession', () => { ); expect(bond.args[0][0].options.currentPlayheadPosition).to.eq(32); }); + + it('accepts currentPlayheadPosition with a value of 0', () => { + const bond = sinon.spy(mp, 'logBaseEvent'); + + const options = { + currentPlayheadPosition: 0, + customAttributes: { + content_rating: 'epic', + }, + }; + + mpMedia.logMediaSessionStart(options); + + expect(bond.args[0][0].options.customAttributes).to.eqls( + options.customAttributes, + ); + expect(bond.args[0][0].options.currentPlayheadPosition).to.eq(0); + }); }); describe('#logMediaSessionEnd', () => {