Skip to content

Commit

Permalink
added feature/getNoBidsForAdUnitCode function (#5932)
Browse files Browse the repository at this point in the history
* added feature/getNoBidsForAdUnitCode function

* added unit test
  • Loading branch information
r-schweitzer authored Nov 16, 2020
1 parent fb32955 commit ac686e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ $$PREBID_GLOBAL$$.getNoBids = function () {
return getBids('getNoBids');
};

/**
* This function returns the bids requests involved in an auction but not bid on or the specified adUnitCode
* @param {string} adUnitCode adUnitCode
* @alias module:pbjs.getNoBidsForAdUnitCode
* @return {Object} bidResponse object
*/

$$PREBID_GLOBAL$$.getNoBidsForAdUnitCode = function (adUnitCode) {
const bids = auctionManager.getNoBids().filter(bid => bid.adUnitCode === adUnitCode);
return { bids };
};

/**
* This function returns the bid responses at the given moment.
* @alias module:pbjs.getBidResponses
Expand Down
6 changes: 5 additions & 1 deletion test/spec/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ describe('Publisher API', function () {
assert.isFunction($$PREBID_GLOBAL$$.getBidResponses);
});

it('should have function $$PREBID_GLOBAL$$.getBidResponses', function () {
it('should have function $$PREBID_GLOBAL$$.getNoBids', function () {
assert.isFunction($$PREBID_GLOBAL$$.getNoBids);
});

it('should have function $$PREBID_GLOBAL$$.getNoBidsForAdUnitCode', function () {
assert.isFunction($$PREBID_GLOBAL$$.getNoBidsForAdUnitCode);
});

it('should have function $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode', function () {
assert.isFunction($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode);
});
Expand Down

0 comments on commit ac686e5

Please sign in to comment.