Skip to content

Commit

Permalink
Adform adapter supports string type sizes (prebid#2692)
Browse files Browse the repository at this point in the history
* Allow to compare strings too.

* Fixed lint errors
  • Loading branch information
Pupis authored and florevallatmrf committed Sep 6, 2018
1 parent e92473d commit 5b4e34d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
5 changes: 2 additions & 3 deletions modules/adformBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ export const spec = {
bidRespones.push(bidObject);
}
}

return bidRespones;

function verifySize(adItem, validSizes) {
for (var j = 0, k = validSizes.length; j < k; j++) {
if (adItem.width === validSizes[j][0] &&
adItem.height === validSizes[j][1]) {
if (adItem.width == validSizes[j][0] &&
adItem.height == validSizes[j][1]) {
return true;
}
}
Expand Down
58 changes: 45 additions & 13 deletions test/spec/modules/adformBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,6 @@ describe('Adform adapter', () => {
let result = spec.interpretResponse({ body: {} }, {});
assert.deepEqual(result, []);
});
it('should respond with empty response when sizes doesn\'t match', () => {
serverResponse.body[0].response = 'banner';
serverResponse.body[0].width = 100;
serverResponse.body[0].height = 150;

serverResponse.body = [serverResponse.body[0]];
bidRequest.bids = [bidRequest.bids[0]];
let result = spec.interpretResponse(serverResponse, bidRequest);

assert.equal(serverResponse.body.length, 1);
assert.equal(serverResponse.body[0].response, 'banner');
assert.deepEqual(result, []);
});
it('should respond with empty response when response from server is not banner', () => {
serverResponse.body[0].response = 'not banner';
serverResponse.body = [serverResponse.body[0]];
Expand Down Expand Up @@ -250,6 +237,51 @@ describe('Adform adapter', () => {
assert.ok(!result[i].gdpr);
assert.ok(!result[i].gdpr_consent);
};
});

describe('verifySizes', () => {
it('should respond with empty response when sizes doesn\'t match', () => {
serverResponse.body[0].response = 'banner';
serverResponse.body[0].width = 100;
serverResponse.body[0].height = 150;

serverResponse.body = [serverResponse.body[0]];
bidRequest.bids = [bidRequest.bids[0]];
let result = spec.interpretResponse(serverResponse, bidRequest);

assert.equal(serverResponse.body.length, 1);
assert.equal(serverResponse.body[0].response, 'banner');
assert.deepEqual(result, []);
});
it('should respond with empty response when sizes as a strings doesn\'t match', () => {
serverResponse.body[0].response = 'banner';
serverResponse.body[0].width = 100;
serverResponse.body[0].height = 150;

serverResponse.body = [serverResponse.body[0]];
bidRequest.bids = [bidRequest.bids[0]];

bidRequest.bids[0].sizes = [['101', '150']];
let result = spec.interpretResponse(serverResponse, bidRequest);

assert.equal(serverResponse.body.length, 1);
assert.equal(serverResponse.body[0].response, 'banner');
assert.deepEqual(result, []);
});
it('should support size dimensions as a strings', () => {
serverResponse.body[0].response = 'banner';
serverResponse.body[0].width = 300;
serverResponse.body[0].height = 600;

serverResponse.body = [serverResponse.body[0]];
bidRequest.bids = [bidRequest.bids[0]];

bidRequest.bids[0].sizes = [['300', '250'], ['250', '300'], ['300', '600'], ['600', '300']]
let result = spec.interpretResponse(serverResponse, bidRequest);

assert.equal(result[0].width, 300);
assert.equal(result[0].height, 600);
});
})
});

Expand Down

0 comments on commit 5b4e34d

Please sign in to comment.