Skip to content

Commit

Permalink
Triplelift Bid Adapter: Support for video floors (#6229)
Browse files Browse the repository at this point in the history
* adds support for getFloor of video mediaTypes

* adds test for calling getFloor with correct mediaType

* checks that _getFloor converts string floors to float

Co-authored-by: Brandon Ling <[email protected]>
  • Loading branch information
nllerandi3lift and Brandon Ling authored Jan 27, 2021
1 parent 7970f51 commit eefd2af
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ function _getFloor (bid) {
if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: 'banner',
size: _sizes(bid.sizes)
mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner',
size: '*'
});
if (typeof floorInfo === 'object' &&
floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
Expand Down
51 changes: 46 additions & 5 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,54 @@ describe('triplelift adapter', function () {
expect(payload.ext).to.deep.equal(undefined);
});
it('should get floor from floors module if available', function() {
const floorInfo = {
currency: 'USD',
floor: 1.99
};
let floorInfo;
bidRequests[0].getFloor = () => floorInfo;
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);

// standard float response; expected functionality of floors module
floorInfo = { currency: 'USD', floor: 1.99 };
let request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].floor).to.equal(1.99);

// if string response, convert to float
floorInfo = { currency: 'USD', floor: '1.99' };
request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].floor).to.equal(1.99);
});
it('should call getFloor with the correct parameters based on mediaType', function() {
bidRequests.forEach(request => {
request.getFloor = () => {};
sinon.spy(request, 'getFloor')
});

tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);

// banner
expect(bidRequests[0].getFloor.calledWith({
currency: 'USD',
mediaType: 'banner',
size: '*'
})).to.be.true;

// instream
expect(bidRequests[1].getFloor.calledWith({
currency: 'USD',
mediaType: 'video',
size: '*'
})).to.be.true;

// banner and incomplete video (POST will only include banner)
expect(bidRequests[3].getFloor.calledWith({
currency: 'USD',
mediaType: 'banner',
size: '*'
})).to.be.true;

// banner and instream (POST will only include video)
expect(bidRequests[5].getFloor.calledWith({
currency: 'USD',
mediaType: 'video',
size: '*'
})).to.be.true;
});
it('should send global config fpd if kvps are available', function() {
const sens = null;
Expand Down

0 comments on commit eefd2af

Please sign in to comment.