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

Adform adapter supports string type sizes #2692

Merged
merged 2 commits into from
Jun 8, 2018
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
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