Skip to content

Commit

Permalink
Added support for video params from mediaTypes obj (#7981)
Browse files Browse the repository at this point in the history
Co-authored-by: pm-azhar-mulla <azhar@L1119.local>
  • Loading branch information
pm-azhar-mulla and pm-azhar-mulla authored Jan 28, 2022
1 parent 0d7faeb commit 20e8c40
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ export const spec = {
bid = deepClone(originalBid);
bid.params.adSlot = bid.params.adSlot || '';
_parseAdSlot(bid);
if (bid.params.hasOwnProperty('video')) {
if ((bid.mediaTypes && bid.mediaTypes.hasOwnProperty('video')) || bid.params.hasOwnProperty('video')) {
// Nothing to do
} else {
// If we have a native mediaType configured alongside banner, its ok if the banner size is not set in width and height
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3861,4 +3861,44 @@ describe('PubMatic adapter', function () {
})
});
});

describe('Video request params', function() {
let sandbox, utilsMock, newVideoRequest;
beforeEach(() => {
utilsMock = sinon.mock(utils);
sandbox = sinon.sandbox.create();
sandbox.spy(utils, 'logWarn');
newVideoRequest = utils.deepClone(videoBidRequests)
});

afterEach(() => {
utilsMock.restore();
sandbox.restore();
})

it('Should log warning if video params from mediaTypes and params obj of bid are not present', function () {
delete newVideoRequest[0].mediaTypes.video;
delete newVideoRequest[0].params.video;

let request = spec.buildRequests(newVideoRequest, {
auctionId: 'new-auction-id'
});

sinon.assert.calledOnce(utils.logWarn);
expect(request).to.equal(undefined);
});

it('Should consider video params from mediaType object of bid', function () {
delete newVideoRequest[0].params.video;

let request = spec.buildRequests(newVideoRequest, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(request.data);
expect(data.imp[0].video).to.exist;
expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]);
expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]);
expect(data.imp[0]['video']['battr']).to.equal(undefined);
});
});
});

0 comments on commit 20e8c40

Please sign in to comment.