Skip to content

Commit

Permalink
fix:accept CurrentPlayheadPosition with 0 value
Browse files Browse the repository at this point in the history
  • Loading branch information
mmustafa-tse committed Sep 5, 2024
1 parent 18a8801 commit 80550ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions test/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 80550ac

Please sign in to comment.