Skip to content

Commit

Permalink
GeoEdge RTD module: collect CPM and curency from the winning bid (#10765
Browse files Browse the repository at this point in the history
)

* Collect CPM and cuurency from the winnning bid

* Export getMacros  for test

* Update tests

---------

Co-authored-by: daniel manan <[email protected]>
  • Loading branch information
GeoEdge-r-and-d and mmndaniel authored Dec 7, 2023
1 parent 4fe6292 commit 8ab882f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/geoedgeRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
};
}

Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/geoedgeRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getInPageUrl,
htmlPlaceholder,
setWrapper,
getMacros,
wrapper,
WRAPPER_URL
} from '../../../modules/geoedgeRtdProvider.js';
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 8ab882f

Please sign in to comment.