Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,11 @@ pbjsInstance.getAllWinningBids = function () {

/**
* Get all of the bids that have won their respective auctions.
* @return {Array<AdapterBidResponse>} A list of bids that have won their respective auctions.
* @deprecated
* @return {Array<AdapterBidResponse>} A list of bids that have won their respective auctions but failed to win the ad server auction.
*/
pbjsInstance.getAllPrebidWinningBids = function () {
logWarn('getAllPrebidWinningBids may be removed or renamed in a future version. This function returns bids that have won in prebid and have had targeting set but have not (yet?) won in the ad server. It excludes bids that have been rendered.');
return auctionManager.getBidsReceived()
.filter(bid => bid.status === BID_STATUS.BID_TARGETING_SET);
};
Expand Down
8 changes: 6 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3874,15 +3874,18 @@ describe('Unit: Prebid Module', function () {

describe('getAllPrebidWinningBids', function () {
let auctionManagerStub;
let logWarnSpy;
beforeEach(function () {
auctionManagerStub = sinon.stub(auctionManager, 'getBidsReceived');
logWarnSpy = sandbox.spy(utils, 'logWarn');
});

afterEach(function () {
auctionManagerStub.restore();
logWarnSpy.restore();
});

it('should return prebid auction winning bids', function () {
it('should warn and return prebid auction winning bids', function () {
let bidsReceived = [
createBidReceived({bidder: 'appnexus', cpm: 7, auctionId: 1, responseTimestamp: 100, adUnitCode: 'code-0', adId: 'adid-1', status: 'targetingSet', requestId: 'reqid-1'}),
createBidReceived({bidder: 'rubicon', cpm: 6, auctionId: 1, responseTimestamp: 101, adUnitCode: 'code-1', adId: 'adid-2', requestId: 'reqid-2'}),
Expand All @@ -3892,8 +3895,9 @@ describe('Unit: Prebid Module', function () {
auctionManagerStub.returns(bidsReceived)
let bids = $$PREBID_GLOBAL$$.getAllPrebidWinningBids();

expect(bids.length).to.equal(1); sandbox
expect(bids.length).to.equal(1);
expect(bids[0].adId).to.equal('adid-1');
sinon.assert.calledOnce(logWarnSpy);
});
});

Expand Down