diff --git a/modules/vrtcalBidAdapter.js b/modules/vrtcalBidAdapter.js index d23a05e23ca..40dab20e078 100644 --- a/modules/vrtcalBidAdapter.js +++ b/modules/vrtcalBidAdapter.js @@ -10,8 +10,17 @@ export const spec = { }, buildRequests: function (bidRequests) { const requests = bidRequests.map(function (bid) { - const params = { + let floor = 0; + + if (typeof bid.getFloor === 'function') { + const floorInfo = bid.getFloor({ currency: 'USD', mediaType: 'banner', size: bid.sizes.map(([w, h]) => ({w, h})) }); + + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = Math.max(floor, parseFloat(floorInfo.floor)); + } + } + const params = { prebidJS: 1, prebidAdUnitCode: bid.adUnitCode, id: bid.bidId, @@ -19,7 +28,7 @@ export const spec = { id: '1', banner: { }, - bidfloor: 0.75 + bidfloor: floor }], site: { id: 'VRTCAL_FILLED', diff --git a/test/spec/modules/vrtcalBidAdapter_spec.js b/test/spec/modules/vrtcalBidAdapter_spec.js index a5f2d475a29..66440130860 100644 --- a/test/spec/modules/vrtcalBidAdapter_spec.js +++ b/test/spec/modules/vrtcalBidAdapter_spec.js @@ -29,7 +29,7 @@ describe('vrtcalBidAdapter', function () { } ]; - const request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests); it('sends bid request to our endpoint via POST', function () { expect(request[0].method).to.equal('POST'); @@ -38,6 +38,18 @@ describe('vrtcalBidAdapter', function () { it('adUnitCode should be sent as prebidAdUnitCode parameters on any requests', function () { expect(request[0].data).to.match(/"prebidAdUnitCode":"adunit0001"/); }); + + it('if the publisher has NOT set a floor via the floors module, zero should be sent as bidfloor parameter on any requests', function () { + expect(request[0].data).to.match(/"bidfloor":0/); + }); + + it('if the publisher has set a floor via the floors module, it should be sent as bidfloor parameter on any requests', function () { + let floorInfo; + bidRequests[0].getFloor = () => floorInfo; + floorInfo = {currency: 'USD', floor: 0.55}; + request = spec.buildRequests(bidRequests); + expect(request[0].data).to.match(/"bidfloor":0.55/); + }); }); describe('interpretResponse', function () {