Skip to content
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

Merged
merged 7 commits into from
May 10, 2019

Conversation

sumit116
Copy link
Contributor

@sumit116 sumit116 commented May 7, 2019

Type of change

  • Bugfix

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:

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);
Copy link
Collaborator

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)

Copy link
Contributor Author

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() {
Copy link
Collaborator

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'}
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sumit Sharma added 2 commits May 10, 2019 14:37
@jaiminpanchal27 jaiminpanchal27 merged commit f78b8e9 into master May 10, 2019
@sumit116
Copy link
Contributor Author

Docs PR: prebid/prebid.github.io#1357

VideoReach pushed a commit to VideoReach/Prebid.js that referenced this pull request Aug 1, 2019
* add adUnitCodes as param for setTargetingForAst()

* unit tests for setTargetingForAst

* refactor

* Revert "refactor"

This reverts commit 1a89d02.

* refactor to add more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants