-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where the ${AUCTION_PRICE} macro was not being replaced in …
…secure creatives (#3493) * fixed issue where the creative AUCTION_PRICE macro was not being replaced in secure creatives. * fixed issue where the creative AUCTION_PRICE macro was not being replaced in secure creatives. * removed cpm from postMessage payload] * removed unneeded cpm deconstruct * pulling cpm from the adObject * also macro repalce adUrl * added unit test for secureCreative sendAdToCreative * added more realistic mock values
- Loading branch information
1 parent
6c196a0
commit 90afc1a
Showing
2 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
_sendAdToCreative | ||
} from '../../../src/secureCreatives'; | ||
import { expect } from 'chai'; | ||
import * as utils from 'src/utils'; | ||
|
||
describe('secureCreatives', () => { | ||
describe('_sendAdToCreative', () => { | ||
beforeEach(function () { | ||
sinon.stub(utils, 'logError'); | ||
sinon.stub(utils, 'logWarn'); | ||
}); | ||
|
||
afterEach(function () { | ||
utils.logError.restore(); | ||
utils.logWarn.restore(); | ||
}); | ||
it('should macro replace ${AUCTION_PRICE} with the winning bid for ad and adUrl', () => { | ||
const oldVal = window.googletag; | ||
const oldapntag = window.apntag; | ||
window.apntag = null | ||
window.googletag = null; | ||
const mockAdObject = { | ||
adId: 'someAdId', | ||
ad: '<script src="http://prebid.org/creative/${AUCTION_PRICE}"></script>', | ||
adUrl: 'http://creative.prebid.org/${AUCTION_PRICE}', | ||
width: 300, | ||
height: 250, | ||
renderer: null, | ||
cpm: '1.00', | ||
adUnitCode: 'some_dom_id' | ||
}; | ||
const remoteDomain = '*'; | ||
const source = { | ||
postMessage: sinon.stub() | ||
}; | ||
|
||
_sendAdToCreative(mockAdObject, remoteDomain, source); | ||
expect(JSON.parse(source.postMessage.args[0][0]).ad).to.equal('<script src="http://prebid.org/creative/1.00"></script>'); | ||
expect(JSON.parse(source.postMessage.args[0][0]).adUrl).to.equal('http://creative.prebid.org/1.00'); | ||
window.googletag = oldVal; | ||
window.apntag = oldapntag; | ||
}); | ||
}); | ||
}); |