Skip to content

Commit

Permalink
Fix support for multi size in Criteo adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfaure committed May 24, 2018
1 parent 47654b7 commit dcea248
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const spec = {

if (body && body.slots && utils.isArray(body.slots)) {
body.slots.forEach(slot => {
const bidRequest = request.bidRequests.find(b => b.adUnitCode === slot.impid && b.params.zoneId === slot.zoneid);
const bidRequest = request.bidRequests.find(b => b.adUnitCode === slot.impid && (!b.params.zoneId || parseInt(b.params.zoneId) === slot.zoneid));
const bidId = bidRequest.bidId;
const bid = {
requestId: bidId,
Expand Down
67 changes: 66 additions & 1 deletion test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('The Criteo bidding adapter', () => {
expect(bids).to.have.lengthOf(0);
});

it('should properly parse a bid response', () => {
it('should properly parse a bid response with a networkId', () => {
const response = {
body: {
slots: [{
Expand All @@ -195,6 +195,71 @@ describe('The Criteo bidding adapter', () => {
bidRequests: [{
adUnitCode: 'test-requestId',
bidId: 'test-bidId',
params: {
networkId: 456,
}
}]
};
const bids = spec.interpretResponse(response, request);
expect(bids).to.have.lengthOf(1);
expect(bids[0].requestId).to.equal('test-bidId');
expect(bids[0].cpm).to.equal(1.23);
expect(bids[0].ad).to.equal('test-ad');
expect(bids[0].width).to.equal(728);
expect(bids[0].height).to.equal(90);
});

it('should properly parse a bid responsewith with a zoneId', () => {
const response = {
body: {
slots: [{
impid: 'test-requestId',
cpm: 1.23,
creative: 'test-ad',
width: 728,
height: 90,
zoneid: 123,
}],
},
};
const request = {
bidRequests: [{
adUnitCode: 'test-requestId',
bidId: 'test-bidId',
params: {
zoneId: 123,
},
}]
};
const bids = spec.interpretResponse(response, request);
expect(bids).to.have.lengthOf(1);
expect(bids[0].requestId).to.equal('test-bidId');
expect(bids[0].cpm).to.equal(1.23);
expect(bids[0].ad).to.equal('test-ad');
expect(bids[0].width).to.equal(728);
expect(bids[0].height).to.equal(90);
});

it('should properly parse a bid responsewith with a zoneId passed as a string', () => {
const response = {
body: {
slots: [{
impid: 'test-requestId',
cpm: 1.23,
creative: 'test-ad',
width: 728,
height: 90,
zoneid: 123,
}],
},
};
const request = {
bidRequests: [{
adUnitCode: 'test-requestId',
bidId: 'test-bidId',
params: {
zoneId: '123',
},
}]
};
const bids = spec.interpretResponse(response, request);
Expand Down

0 comments on commit dcea248

Please sign in to comment.