Skip to content

Commit

Permalink
Yieldnexus: Add video player size (#3727)
Browse files Browse the repository at this point in the history
* Add support for multiple media types. Add test coverage.

* Add support for multiple media types. Add test coverage.

* Modify multi-format ads handler. Modify tests.

* Rename yieldnexus bid adapter to fix download issue

* Set video player according to playerSize (if given).
Add unit test.

* Fix lint issues
  • Loading branch information
sa1omon authored and robertrmartinez committed Apr 16, 2019
1 parent 2431715 commit cc2f394
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modules/yieldnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,23 @@ export const spec = {

if (bidRequest.mediaTypes && bidRequest.mediaTypes.video) {
imp.video = {
w: bidRequest.sizes.length ? bidRequest.sizes[0][0] : 300,
h: bidRequest.sizes.length ? bidRequest.sizes[0][1] : 250,
protocols: bidRequest.params.protocols || [1, 2, 3, 4, 5, 6],
pos: bidRequest.params.pos || 0,
topframe: topFrame
};

let playerSize = bidRequest.mediaTypes.video.playerSize;
if (playerSize && utils.isArray(playerSize[0])) {
imp.video.w = playerSize[0][0];
imp.video.h = playerSize[0][1];
} else if (playerSize && utils.isNumber(playerSize[0])) {
imp.video.w = playerSize[0];
imp.video.h = playerSize[1];
} else {
playerSize = utils.isArray(bidRequest.sizes) ? bidRequest.sizes[0] : [300, 250];
imp.video.w = playerSize[0];
imp.video.h = playerSize[1];
}
}

if (!bidRequest.mediaTypes || bidRequest.mediaTypes.banner) {
Expand Down
21 changes: 21 additions & 0 deletions test/spec/modules/yieldnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ describe('YieldNexusAdapter', () => {
response = spec.buildRequests([bidRequestWithPosEquals1])[0];
expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos);
});

it('builds request video object correctly with multi-dimensions size array', function () {
let bidRequestWithVideo = utils.deepClone(bidRequest);
bidRequestWithVideo.mediaTypes.video = {
playerSize: [[304, 254], [305, 255]],
context: 'instream'
};

let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0];
expect(response.data.imp[0].video.w).to.equal(304);
expect(response.data.imp[0].video.h).to.equal(254);

bidRequestWithVideo = utils.deepClone(bidRequest);
bidRequestWithVideo.mediaTypes.video = {
playerSize: [304, 254]
};

response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0];
expect(response.data.imp[0].video.w).to.equal(304);
expect(response.data.imp[0].video.h).to.equal(254);
});
});
describe('interpretResponse', () => {
const bannerBidRequest = {
Expand Down

0 comments on commit cc2f394

Please sign in to comment.