Skip to content

Commit

Permalink
Revert breaking change (prebid#3052)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiminpanchal27 authored and StefanWallin committed Sep 28, 2018
1 parent 417098f commit a64c6a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
7 changes: 4 additions & 3 deletions src/prebid.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** @module pbjs */

import { getGlobal } from './prebidGlobal';
import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, removeRequestId } from './utils';
import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, removeRequestId, getLatestHighestCpmBid } from './utils';
import { listenMessagesFromCreative } from './secureCreatives';
import { userSync } from 'src/userSync.js';
import { loadScript } from './adloader';
import { config } from './config';
import { auctionManager } from './auctionManager';
import { targeting, RENDERED, BID_TARGETING_SET } from './targeting';
import { targeting, getHighestCpmBidsFromBidPool, RENDERED, BID_TARGETING_SET } from './targeting';
import { createHook } from 'src/hook';
import { sessionLoader } from 'src/debugging';
import includes from 'core-js/library/fn/array/includes';
Expand Down Expand Up @@ -597,7 +597,8 @@ $$PREBID_GLOBAL$$.getAllPrebidWinningBids = function () {
* @return {Array} array containing highest cpm bid object(s)
*/
$$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) {
return targeting.getWinningBids(adUnitCode)
let bidsReceived = getHighestCpmBidsFromBidPool(auctionManager.getBidsReceived(), getLatestHighestCpmBid);
return targeting.getWinningBids(adUnitCode, bidsReceived)
.map(removeRequestId);
};

Expand Down
29 changes: 8 additions & 21 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1810,10 +1810,13 @@ describe('Unit: Prebid Module', function () {
});
});

describe('getHighestCpm', function () {
after(function () {
resetAuction();
});
describe('getHighestCpm', () => {
// it('returns an array of winning bid objects for each adUnit', () => {
// const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids();
// expect(highestCpmBids.length).to.equal(2);
// expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[1]);
// expect(highestCpmBids[1]).to.deep.equal(auctionManager.getBidsReceived()[2]);
// });

it('returns an array containing the highest bid object for the given adUnitCode', function () {
const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0');
Expand All @@ -1833,23 +1836,7 @@ describe('Unit: Prebid Module', function () {

const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0');
expect(highestCpmBids.length).to.equal(0);
});

it('should not return rendered bid', function() {
let _bidsReceived = getBidResponses().slice(0, 3);
_bidsReceived[0].cpm = 12;
_bidsReceived[0].status = 'rendered';
_bidsReceived[1].cpm = 9;
_bidsReceived[2].cpm = 11;

_bidsReceived.forEach((bid) => {
bid.adUnitCode = '/19968336/header-bid-tag-0';
});

auction.getBidsReceived = function() { return _bidsReceived };

const highestCpmBids = $$PREBID_GLOBAL$$.getHighestCpmBids('/19968336/header-bid-tag-0');
expect(highestCpmBids[0]).to.deep.equal(auctionManager.getBidsReceived()[2]);
resetAuction();
});
});

Expand Down

0 comments on commit a64c6a8

Please sign in to comment.