Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yieldnexus: Add video player size #3727

Merged
merged 10 commits into from
Apr 16, 2019
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