Skip to content

Commit

Permalink
fix mismatch (#11208)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikagotso authored Mar 14, 2024
1 parent 77254c2 commit b8a8031
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 8 deletions.
23 changes: 15 additions & 8 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,11 @@ export const spec = {
}
iv = iv || getBidIdParameter('iv', bid.params)

const floorInfo = (bid.getFloor && typeof bid.getFloor === 'function') ? bid.getFloor({
currency: 'USD',
mediaType: bid.mediaTypes && bid.mediaTypes.banner ? 'banner' : 'video',
size: '*'
}) : {}
floorInfo.floor = floorInfo.floor || getBidIdParameter('bidfloor', bid.params)

const imp = {
adunitcode: bid.adUnitCode,
id: bid.bidId,
tagid: String(getBidIdParameter('tagid', bid.params)),
bidfloor: floorInfo.floor
bidfloor: _getBidFloors(bid)
}

if (deepAccess(bid, 'mediaTypes.banner')) {
Expand Down Expand Up @@ -332,4 +325,18 @@ function _buildVideoRequestObj(bid) {
return videoObj
}

function _getBidFloors(bid) {
const floorInfo = (bid.getFloor && typeof bid.getFloor === 'function') ? bid.getFloor({
currency: 'USD',
mediaType: bid.mediaTypes && bid.mediaTypes.banner ? 'banner' : 'video',
size: '*'
}) : {}
const floorModuleValue = parseFloat(floorInfo.floor)
if (!isNaN(floorModuleValue)) {
return floorModuleValue
}
const paramValue = parseFloat(getBidIdParameter('bidfloor', bid.params))
return !isNaN(paramValue) ? paramValue : undefined
}

registerBidder(spec)
39 changes: 39 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,45 @@ describe('sovrnBidAdapter', function() {

expect(impression.bidfloor).to.equal(2.00)
})
it('floor should be undefined if there is no floor from the floor module and params', function() {
const floorBid = {
...baseBidRequest
}
floorBid.params = {
tagid: 1234
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
it('floor should be undefined if there is incorrect floor value from the floor module', function() {
const floorBid = {
...baseBidRequest,
getFloor: () => ({currency: 'USD', floor: 'incorrect_value'}),
params: {
tagid: 1234
}
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
it('floor should be undefined if there is incorrect floor value from the params', function() {
const floorBid = {
...baseBidRequest,
getFloor: () => ({})
}
floorBid.params = {
tagid: 1234,
bidfloor: 'incorrect_value'
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
describe('First Party Data', function () {
it('should provide first party data if provided', function() {
const ortb2 = {
Expand Down

0 comments on commit b8a8031

Please sign in to comment.