From 8ab882f324ae71ff38252ebc9e7c3a7ac73b485c Mon Sep 17 00:00:00 2001 From: GeoEdge-r-and-d <72186958+GeoEdge-r-and-d@users.noreply.github.com> Date: Thu, 7 Dec 2023 18:23:01 +0200 Subject: [PATCH] GeoEdge RTD module: collect CPM and curency from the winning bid (#10765) * Collect CPM and cuurency from the winnning bid * Export getMacros for test * Update tests --------- Co-authored-by: daniel manan --- modules/geoedgeRtdProvider.js | 6 ++++-- test/spec/modules/geoedgeRtdProvider_spec.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/geoedgeRtdProvider.js b/modules/geoedgeRtdProvider.js index 646d2f4e786..afaaef93169 100644 --- a/modules/geoedgeRtdProvider.js +++ b/modules/geoedgeRtdProvider.js @@ -103,7 +103,7 @@ export function wrapHtml(wrapper, html) { * @param {string} key * @return {Object} */ -function getMacros(bid, key) { +export function getMacros(bid, key) { return { '${key}': key, '%%ADUNIT%%': bid.adUnitCode, @@ -116,7 +116,9 @@ function getMacros(bid, key) { '%_hbadomains': bid.meta && bid.meta.advertiserDomains, '%%PATTERN:hb_pb%%': bid.pbHg, '%%SITE%%': location.hostname, - '%_pimp%': PV_ID + '%_pimp%': PV_ID, + '%_hbCpm!': bid.cpm, + '%_hbCurrency!': bid.currency }; } diff --git a/test/spec/modules/geoedgeRtdProvider_spec.js b/test/spec/modules/geoedgeRtdProvider_spec.js index 96da2e3dbd7..b0307a60a3c 100644 --- a/test/spec/modules/geoedgeRtdProvider_spec.js +++ b/test/spec/modules/geoedgeRtdProvider_spec.js @@ -6,6 +6,7 @@ import { getInPageUrl, htmlPlaceholder, setWrapper, + getMacros, wrapper, WRAPPER_URL } from '../../../modules/geoedgeRtdProvider.js'; @@ -117,6 +118,15 @@ describe('Geoedge RTD module', function () { expect(wrapper).to.equal(mockWrapper); }); }); + describe('getMacros', function () { + it('return a dictionary of macros replaced with values from bid object', function () { + let bid = mockBid('testBidder'); + let dict = getMacros(bid, key); + let hasCpm = dict['%_hbCpm!'] === bid.cpm; + let hasCurrency = dict['%_hbCurrency!'] === bid.currency; + expect(hasCpm && hasCurrency); + }); + }); describe('onBidResponseEvent', function () { let bidFromA = mockBid('bidderA'); it('should wrap bid html when bidder is configured', function () {