Skip to content

Commit

Permalink
Merge pull request #72 from triplelift-internal/TL-35335-cast-playbac…
Browse files Browse the repository at this point in the history
…kmethod

TL-35335: Cast playbackmethod as array
  • Loading branch information
patrickloughrey authored Mar 1, 2023
2 parents 6bd8a1d + 25664ce commit 7307d1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit 7307d1a

Please sign in to comment.