Skip to content

Commit

Permalink
* fix convertCurrency mock
Browse files Browse the repository at this point in the history
* remove redundant checks for type and NaN from `convertBidFloorCurrency` function
  • Loading branch information
lshishkov committed Oct 11, 2024
1 parent 17f3fa6 commit 9e0a49c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ const convertBidFloorCurrency = (imp) => {
DEFAULT_CURRENCY,
false,
);
if (typeof bidFloor === 'number' && !isNaN(bidFloor)) {
imp.bidfloor = bidFloor;
imp.bidfloorcur = DEFAULT_CURRENCY;
}
imp.bidfloor = bidFloor;
imp.bidfloorcur = DEFAULT_CURRENCY;
} catch (err) {
logWarn(`Failed to convert bid floor to ${DEFAULT_CURRENCY}. Passing floor price in its original currency.`, err);
}
Expand Down
6 changes: 5 additions & 1 deletion test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ describe('Improve Digital Adapter Tests', function () {
getGlobalStub = sinon.stub(prebidGlobal, 'getGlobal').returns({
convertCurrency: (cpm, from, to) => {
const conversionKeys = { 'EUR-USD': 1.75 };
return cpm * conversionKeys[`${from}-${to}`];
const conversionRate = conversionKeys[`${from}-${to}`];
if (!conversionRate) {
throw new Error(`No conversion rate found for ${from}-${to}`);
}
return cpm * conversionRate;
}
});
const bidRequest = deepClone(simpleBidRequest);
Expand Down

0 comments on commit 9e0a49c

Please sign in to comment.