Skip to content

Commit

Permalink
Floor price : allow having a 0$ floor (#8239)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulieLorin authored Mar 30, 2022
1 parent 8a7ebfd commit f79b5b4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function getFirstMatchingFloor(floorData, bidObject, responseObject = {})

let matchingData = {
floorMin: floorData.floorMin || 0,
floorRuleValue: floorData.values[matchingRule] || floorData.default,
floorRuleValue: isNaN(floorData.values[matchingRule]) ? floorData.default : floorData.values[matchingRule],
matchingData: allPossibleMatches[0], // the first possible match is an "exact" so contains all data relevant for anlaytics adapters
matchingRule
};
Expand Down
38 changes: 38 additions & 0 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,44 @@ describe('the price floors module', function () {
});

describe('getFirstMatchingFloor', function () {
it('uses a 0 floor as overrite', function () {
let inputFloorData = {
currency: 'USD',
schema: {
delimiter: '|',
fields: ['adUnitCode']
},
values: {
'test_div_1': 0,
'test_div_2': 2
},
default: 0.5
};

expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({
floorMin: 0,
floorRuleValue: 0,
matchingFloor: 0,
matchingData: 'test_div_1',
matchingRule: 'test_div_1'
});

expect(getFirstMatchingFloor(inputFloorData, {...basicBidRequest, adUnitCode: 'test_div_2'}, {mediaType: 'banner', size: '*'})).to.deep.equal({
floorMin: 0,
floorRuleValue: 2,
matchingFloor: 2,
matchingData: 'test_div_2',
matchingRule: 'test_div_2'
});

expect(getFirstMatchingFloor(inputFloorData, {...basicBidRequest, adUnitCode: 'test_div_3'}, {mediaType: 'banner', size: '*'})).to.deep.equal({
floorMin: 0,
floorRuleValue: 0.5,
matchingFloor: 0.5,
matchingData: 'test_div_3',
matchingRule: undefined
});
});
it('selects the right floor for different mediaTypes', function () {
// banner with * size (not in rule file so does not do anything)
expect(getFirstMatchingFloor({...basicFloorData}, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({
Expand Down

0 comments on commit f79b5b4

Please sign in to comment.