Skip to content

Commit

Permalink
ZetaGlobalSsp Bid Adapter : process array of sizes (prebid#10039)
Browse files Browse the repository at this point in the history
* ZetaGlobalSsp: process all sizes in banner.format

* Fix linting

---------

Co-authored-by: Surovenko Alexey <[email protected]>
Co-authored-by: Alexey Surovenko <[email protected]>
Co-authored-by: Chris Huie <[email protected]>
  • Loading branch information
4 people authored and Michele Nasti committed Aug 25, 2023
1 parent ee7832a commit 3db33c4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
22 changes: 18 additions & 4 deletions modules/zeta_global_sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,24 @@ function buildBanner(request) {
request.mediaTypes.banner.sizes) {
sizes = request.mediaTypes.banner.sizes;
}
return {
w: sizes[0][0],
h: sizes[0][1]
};
if (sizes.length > 1) {
const format = sizes.map(s => {
return {
w: s[0],
h: s[1]
}
});
return {
w: sizes[0][0],
h: sizes[0][1],
format: format
}
} else {
return {
w: sizes[0][0],
h: sizes[0][1]
}
}
}

function buildVideo(request) {
Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/zeta_global_sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@ describe('Zeta Ssp Bid Adapter', function () {
timeout: 500
}];

const bannerWithFewSizesRequest = [{
bidId: 12345,
auctionId: 67890,
mediaTypes: {
banner: {
sizes: [[300, 250], [200, 240], [100, 150]],
}
},
refererInfo: {
page: 'http://www.zetaglobal.com/page?param=value',
domain: 'www.zetaglobal.com',
},
gdprConsent: {
gdprApplies: 1,
consentString: 'consentString'
},
schain: schain,
uspConsent: 'someCCPAString',
params: params,
userIdAsEids: eids,
timeout: 500
}];

const videoRequest = [{
bidId: 112233,
auctionId: 667788,
Expand Down Expand Up @@ -408,4 +431,38 @@ describe('Zeta Ssp Bid Adapter', function () {

expect(payload.imp[0].tagid).to.eql(params.tagid);
});

it('Test if only one size', function () {
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
const payload = JSON.parse(request.data);

// banner
expect(payload.imp[0].banner.w).to.eql(300);
expect(payload.imp[0].banner.h).to.eql(250);

expect(payload.imp[0].banner.format).to.be.undefined;
});

it('Test few sizes provided in format', function () {
const request = spec.buildRequests(bannerWithFewSizesRequest, bannerWithFewSizesRequest[0]);
const payload = JSON.parse(request.data);

// banner
expect(payload.imp[0].banner.w).to.eql(300);
expect(payload.imp[0].banner.h).to.eql(250);

expect(payload.imp[0].banner.format.length).to.eql(3);

// format[0]
expect(payload.imp[0].banner.format[0].w).to.eql(300);
expect(payload.imp[0].banner.format[0].h).to.eql(250);

// format[1]
expect(payload.imp[0].banner.format[1].w).to.eql(200);
expect(payload.imp[0].banner.format[1].h).to.eql(240);

// format[2]
expect(payload.imp[0].banner.format[2].w).to.eql(100);
expect(payload.imp[0].banner.format[2].h).to.eql(150);
});
});

0 comments on commit 3db33c4

Please sign in to comment.