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

TL-35335: Cast playbackmethod as array #72

Merged
merged 1 commit into from
Mar 1, 2023
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
3 changes: 3 additions & 0 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ function _getORTBVideo(bidRequest) {
video.placement = 3
}
}
if (video.playbackmethod && Number.isInteger(video.playbackmethod)) {
video.playbackmethod = Array.from(String(video.playbackmethod), Number);
}

// clean up oRTB object
delete video.playerSize;
Expand Down
16 changes: 14 additions & 2 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ describe('triplelift adapter', function () {
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
playerSize: [640, 480],
playbackmethod: 5
}
},
adUnitCode: 'adunit-code-instream',
Expand Down Expand Up @@ -292,7 +293,8 @@ describe('triplelift adapter', function () {
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
playerSize: [640, 480],
playbackmethod: [1, 2, 3]
},
banner: {
sizes: [
Expand Down Expand Up @@ -1181,6 +1183,16 @@ describe('triplelift adapter', function () {
'gpp_sid': [7]
})
});
it('should cast playbackmethod as an array if it is an integer and it exists', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[1].video.playbackmethod).to.be.a('array');
expect(request.data.imp[1].video.playbackmethod).to.deep.equal([5]);
});
it('should set playbackmethod as an array if it exists as an array', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[5].video.playbackmethod).to.be.a('array');
expect(request.data.imp[5].video.playbackmethod).to.deep.equal([1, 2, 3]);
});
});

describe('interpretResponse', function () {
Expand Down