Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:accept CurrentPlayheadPosition with 0 value #638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
): MediaEvent {
// Set event option based on options or current state
this.currentPlayheadPosition =
options?.currentPlayheadPosition || this.currentPlayheadPosition;
options?.currentPlayheadPosition ?? this.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 Expand Up @@ -692,7 +692,7 @@
this.mediaSessionEndTimestamp = Date.now();
}
// tslint:disable-next-line: no-any
const customAttributes: Record<string, any> = {};

Check warning on line 695 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type

Check warning on line 695 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type
customAttributes[
ValidMediaAttributeKeys.mediaSessionIdKey
] = this.sessionId;
Expand Down Expand Up @@ -754,7 +754,7 @@
}

// tslint:disable-next-line: no-any
const customAttributes: Record<string, any> = {};

Check warning on line 757 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type

Check warning on line 757 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type
customAttributes[
ValidMediaAttributeKeys.mediaSessionIdKey
] = this.sessionId;
Expand Down Expand Up @@ -810,7 +810,7 @@
}

// tslint:disable-next-line: no-any
const customAttributes: Record<string, any> = {};

Check warning on line 813 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type

Check warning on line 813 in src/session.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

Unexpected any. Specify a different type
customAttributes[
ValidMediaAttributeKeys.mediaSessionIdKey
] = this.sessionId;
Expand Down
18 changes: 18 additions & 0 deletions test/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
beforeEach(() => {
sandbox = sinon.createSandbox();
mp = {
logBaseEvent: (event: MediaEvent) => {},

Check warning on line 29 in test/session.test.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

'event' is defined but never used

Check warning on line 29 in test/session.test.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

'event' is defined but never used
logger: (message: string) => {},

Check warning on line 30 in test/session.test.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

'message' is defined but never used

Check warning on line 30 in test/session.test.ts

View workflow job for this annotation

GitHub Actions / Build and Test (14.x)

'message' is defined but never used
};

song = {
Expand Down Expand Up @@ -746,6 +746,24 @@
);
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
Loading