From 9e0a49c09a99e251de4877e681b70f4fbe214d9e Mon Sep 17 00:00:00 2001 From: Lyubomir Shishkov Date: Sat, 12 Oct 2024 00:26:22 +0300 Subject: [PATCH] * fix `convertCurrency` mock * remove redundant checks for type and NaN from `convertBidFloorCurrency` function --- modules/improvedigitalBidAdapter.js | 6 ++---- test/spec/modules/improvedigitalBidAdapter_spec.js | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index 103fdb24e75..c08edb3987d 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -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); } diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 844ded6abe9..0c0789ced48 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -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);