From 25664ce5566e9eb31c7c48d17e5f05cac9c711b4 Mon Sep 17 00:00:00 2001 From: Patrick Loughrey Date: Wed, 1 Mar 2023 14:20:12 -0500 Subject: [PATCH] TL-35335: Cast playbackmethod as array --- modules/tripleliftBidAdapter.js | 3 +++ test/spec/modules/tripleliftBidAdapter_spec.js | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 8012a4a8051..1f654d34c6a 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -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; diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 221ffb8371f..4debf516f89 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -167,7 +167,8 @@ describe('triplelift adapter', function () { mediaTypes: { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [640, 480], + playbackmethod: 5 } }, adUnitCode: 'adunit-code-instream', @@ -292,7 +293,8 @@ describe('triplelift adapter', function () { mediaTypes: { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [640, 480], + playbackmethod: [1, 2, 3] }, banner: { sizes: [ @@ -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 () {