Skip to content

Commit

Permalink
Taboola Bid Adapter: Fixing Accepting Bid Floor Mechanism (#9279)
Browse files Browse the repository at this point in the history
* use-convention-for-bidfloor-extraction

* use-convention-for-bidfloor-extraction

* add-unit-tests
  • Loading branch information
ahmadlob authored Dec 8, 2022
1 parent 4346aa8 commit f5f276b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
27 changes: 20 additions & 7 deletions modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,28 @@ function getSiteProperties({publisherId, bcat = []}, refererInfo) {

function getImps(validBidRequests) {
return validBidRequests.map((bid, id) => {
const {tagId, bidfloor = null, bidfloorcur = CURRENCY} = bid.params;

return {
const {tagId} = bid.params;
const imp = {
id: id + 1,
banner: getBanners(bid),
tagid: tagId,
bidfloor,
bidfloorcur,
};
tagid: tagId
}
if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({
currency: CURRENCY,
mediaType: BANNER,
size: '*'
});
if (typeof floorInfo === 'object' && floorInfo.currency === CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
imp.bidfloor = parseFloat(floorInfo.floor);
imp.bidfloorcur = CURRENCY;
}
} else {
const {bidfloor = null, bidfloorcur = CURRENCY} = bid.params;
imp.bidfloor = bidfloor;
imp.bidfloorcur = bidfloorcur;
}
return imp;
});
}

Expand Down
39 changes: 39 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,45 @@ describe('Taboola Adapter', function () {
expect(resData.imp[0].bidfloorcur).to.deep.equal('EUR');
});

it('should pass bid floor', function () {
const bidRequest = {
...defaultBidRequest,
params: {...commonBidRequest.params},
getFloor: function() {
return {
currency: 'USD',
floor: 2.7,
}
}
};
const res = spec.buildRequests([bidRequest], commonBidderRequest);
const resData = JSON.parse(res.data);
expect(resData.imp[0].bidfloor).to.deep.equal(2.7);
expect(resData.imp[0].bidfloorcur).to.deep.equal('USD');
});

it('should pass bid floor even if they is a bid floor param', function () {
const optionalParams = {
bidfloor: 0.25,
bidfloorcur: 'EUR'
};

const bidRequest = {
...defaultBidRequest,
params: {...commonBidRequest.params, ...optionalParams},
getFloor: function() {
return {
currency: 'USD',
floor: 2.7,
}
}
};
const res = spec.buildRequests([bidRequest], commonBidderRequest);
const resData = JSON.parse(res.data);
expect(resData.imp[0].bidfloor).to.deep.equal(2.7);
expect(resData.imp[0].bidfloorcur).to.deep.equal('USD');
});

it('should pass bidder timeout', function () {
const bidderRequest = {
...commonBidderRequest,
Expand Down

0 comments on commit f5f276b

Please sign in to comment.