Skip to content

Commit 3db33c4

Browse files
asurovenko-zetasurovenkoAlexey SurovenkoChrisHuie
authored and
Michele Nasti
committed
ZetaGlobalSsp Bid Adapter : process array of sizes (prebid#10039)
* 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]>
1 parent ee7832a commit 3db33c4

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

modules/zeta_global_sspBidAdapter.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,24 @@ function buildBanner(request) {
264264
request.mediaTypes.banner.sizes) {
265265
sizes = request.mediaTypes.banner.sizes;
266266
}
267-
return {
268-
w: sizes[0][0],
269-
h: sizes[0][1]
270-
};
267+
if (sizes.length > 1) {
268+
const format = sizes.map(s => {
269+
return {
270+
w: s[0],
271+
h: s[1]
272+
}
273+
});
274+
return {
275+
w: sizes[0][0],
276+
h: sizes[0][1],
277+
format: format
278+
}
279+
} else {
280+
return {
281+
w: sizes[0][0],
282+
h: sizes[0][1]
283+
}
284+
}
271285
}
272286

273287
function buildVideo(request) {

test/spec/modules/zeta_global_sspBidAdapter_spec.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ describe('Zeta Ssp Bid Adapter', function () {
127127
timeout: 500
128128
}];
129129

130+
const bannerWithFewSizesRequest = [{
131+
bidId: 12345,
132+
auctionId: 67890,
133+
mediaTypes: {
134+
banner: {
135+
sizes: [[300, 250], [200, 240], [100, 150]],
136+
}
137+
},
138+
refererInfo: {
139+
page: 'http://www.zetaglobal.com/page?param=value',
140+
domain: 'www.zetaglobal.com',
141+
},
142+
gdprConsent: {
143+
gdprApplies: 1,
144+
consentString: 'consentString'
145+
},
146+
schain: schain,
147+
uspConsent: 'someCCPAString',
148+
params: params,
149+
userIdAsEids: eids,
150+
timeout: 500
151+
}];
152+
130153
const videoRequest = [{
131154
bidId: 112233,
132155
auctionId: 667788,
@@ -408,4 +431,38 @@ describe('Zeta Ssp Bid Adapter', function () {
408431

409432
expect(payload.imp[0].tagid).to.eql(params.tagid);
410433
});
434+
435+
it('Test if only one size', function () {
436+
const request = spec.buildRequests(bannerRequest, bannerRequest[0]);
437+
const payload = JSON.parse(request.data);
438+
439+
// banner
440+
expect(payload.imp[0].banner.w).to.eql(300);
441+
expect(payload.imp[0].banner.h).to.eql(250);
442+
443+
expect(payload.imp[0].banner.format).to.be.undefined;
444+
});
445+
446+
it('Test few sizes provided in format', function () {
447+
const request = spec.buildRequests(bannerWithFewSizesRequest, bannerWithFewSizesRequest[0]);
448+
const payload = JSON.parse(request.data);
449+
450+
// banner
451+
expect(payload.imp[0].banner.w).to.eql(300);
452+
expect(payload.imp[0].banner.h).to.eql(250);
453+
454+
expect(payload.imp[0].banner.format.length).to.eql(3);
455+
456+
// format[0]
457+
expect(payload.imp[0].banner.format[0].w).to.eql(300);
458+
expect(payload.imp[0].banner.format[0].h).to.eql(250);
459+
460+
// format[1]
461+
expect(payload.imp[0].banner.format[1].w).to.eql(200);
462+
expect(payload.imp[0].banner.format[1].h).to.eql(240);
463+
464+
// format[2]
465+
expect(payload.imp[0].banner.format[2].w).to.eql(100);
466+
expect(payload.imp[0].banner.format[2].h).to.eql(150);
467+
});
411468
});

0 commit comments

Comments
 (0)