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

TL-19515 Support video floors #17

Merged
3 commits merged into from
Jan 26, 2021
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
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