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

Add support for multiple sizes #5626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not believe this tests the code change.

You'll need to probably build the requests spec.buildRequests and validate data.bf is present and looks correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new unit test for this; thanks for calling that out :)

});

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
describe('floorModule', function () {
const floorTestData = {
'currency': 'USD',
Expand Down