Skip to content

Commit

Permalink
GumGumBidAdapter: Add support for multiple sizes (#5626)
Browse files Browse the repository at this point in the history
add UT


UT

Co-authored-by: Estavillo <fernando@gumgum.com>
  • Loading branch information
estavillo and Estavillo authored Sep 8, 2020
1 parent d41a946 commit 0d3c632
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
11 changes: 11 additions & 0 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ function buildRequests (validBidRequests, bidderRequest) {
}
if (params.inSlot) {
data.si = parseInt(params.inSlot, 10);
// check for sizes and type
if (params.sizes && Array.isArray(params.sizes)) {
const bf = params.sizes.reduce(function(r, i) {
// only push if it's an array of length 2
if (Array.isArray(i) && i.length === 2) {
r.push(`${i[0]}x${i[1]}`);
}
return r;
}, []);
data.bf = bf.toString();
}
data.pi = 3;
}
if (params.ICV) {
Expand Down
25 changes: 23 additions & 2 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ describe('gumgumAdapter', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});

it('should return true when inslot sends sizes and trackingid', function () {
let bid = Object.assign({}, bid);
delete bid.params;
bid.params = {
'inSlot': '789',
'sizes': [[0, 1], [2, 3], [4, 5], [6, 7]]
};

expect(spec.isBidRequestValid(bid)).to.equal(true);
});

it('should return false when no unit type is specified', function () {
let bid = Object.assign({}, bid);
delete bid.params;
Expand Down Expand Up @@ -81,14 +92,15 @@ describe('gumgumAdapter', function () {
});

describe('buildRequests', function () {
let sizesArray = [[300, 250], [300, 600]];
let bidRequests = [
{
'bidder': 'gumgum',
'params': {
'inSlot': '9'
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [300, 600]],
'sizes': sizesArray,
'bidId': '30b31c1838de1e',
'schain': {
'ver': '1.0',
Expand Down Expand Up @@ -132,7 +144,16 @@ describe('gumgumAdapter', function () {
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.sizes).to.equal(vidMediaTypes.video.playerSize);
});

it('should handle multiple sizes for inslot', function () {
const request = Object.assign({}, bidRequests[0]);
delete request.params;
request.params = {
'inSlot': '123',
'sizes': [[0, 1], [0, 2]]
};
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.bf).to.equal('0x1,0x2');
});
describe('floorModule', function () {
const floorTestData = {
'currency': 'USD',
Expand Down

0 comments on commit 0d3c632

Please sign in to comment.