-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rad 2751/specify ad units set targeting for ast #3805
Rad 2751/specify ad units set targeting for ast #3805
Conversation
…-2751/specify-adUnits-setTargetingForAST
…-2751/specify-adUnits-setTargetingForAST
targetingInstance.setTargetingForAst(adUnitCodes); | ||
expect(targetingInstance.getAllTargeting.called).to.equal(true); | ||
expect(targetingInstance.resetPresetTargetingAST.called).to.equal(true); | ||
expect(window.apntag.setKeywords.called).to.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To differentiate between this test and the one with single adUnitCode, you should test here that window.apntag.setKeywords
executed twice. Also another assertion can be called with args. Check this sinonjs/sinon#953 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the tests.
|
||
function mockGetAllTargeting(adUnitCodes) { | ||
adUnitCodes = Array.isArray(adUnitCodes) ? adUnitCodes : Array(adUnitCodes); | ||
sandbox.stub(targetingInstance, 'getAllTargeting').callsFake(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest here to use stub.returns
. Changing the implementation of getAllTargeting with this fake function is not a good idea. So you can do something like below in each test case
targetingStub.returns({
'adUnitCode': {hb_bidder:'appnexus'}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This reverts commit 1a89d02.
Docs PR: prebid/prebid.github.io#1357 |
* add adUnitCodes as param for setTargetingForAst() * unit tests for setTargetingForAst * refactor * Revert "refactor" This reverts commit 1a89d02. * refactor to add more tests
Type of change
Description of change
Added Unit tests for setTargetingForAst()
Be sure to test the integration with your adserver using the Hello World sample page.
For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide: