Skip to content

Commit 7307d1a

Browse files
Merge pull request #72 from triplelift-internal/TL-35335-cast-playbackmethod
TL-35335: Cast playbackmethod as array
2 parents 6bd8a1d + 25664ce commit 7307d1a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

modules/tripleliftBidAdapter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ function _getORTBVideo(bidRequest) {
195195
video.placement = 3
196196
}
197197
}
198+
if (video.playbackmethod && Number.isInteger(video.playbackmethod)) {
199+
video.playbackmethod = Array.from(String(video.playbackmethod), Number);
200+
}
198201

199202
// clean up oRTB object
200203
delete video.playerSize;

test/spec/modules/tripleliftBidAdapter_spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ describe('triplelift adapter', function () {
167167
mediaTypes: {
168168
video: {
169169
context: 'instream',
170-
playerSize: [640, 480]
170+
playerSize: [640, 480],
171+
playbackmethod: 5
171172
}
172173
},
173174
adUnitCode: 'adunit-code-instream',
@@ -292,7 +293,8 @@ describe('triplelift adapter', function () {
292293
mediaTypes: {
293294
video: {
294295
context: 'instream',
295-
playerSize: [640, 480]
296+
playerSize: [640, 480],
297+
playbackmethod: [1, 2, 3]
296298
},
297299
banner: {
298300
sizes: [
@@ -1181,6 +1183,16 @@ describe('triplelift adapter', function () {
11811183
'gpp_sid': [7]
11821184
})
11831185
});
1186+
it('should cast playbackmethod as an array if it is an integer and it exists', function() {
1187+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
1188+
expect(request.data.imp[1].video.playbackmethod).to.be.a('array');
1189+
expect(request.data.imp[1].video.playbackmethod).to.deep.equal([5]);
1190+
});
1191+
it('should set playbackmethod as an array if it exists as an array', function() {
1192+
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
1193+
expect(request.data.imp[5].video.playbackmethod).to.be.a('array');
1194+
expect(request.data.imp[5].video.playbackmethod).to.deep.equal([1, 2, 3]);
1195+
});
11841196
});
11851197

11861198
describe('interpretResponse', function () {

0 commit comments

Comments
 (0)