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

Pass timedOut as argument to bidsBackHandler function #2772

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
6 changes: 3 additions & 3 deletions src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels})
try {
_auctionStatus = AUCTION_COMPLETED;
const adUnitCodes = _adUnitCodes;
const bids = [_bidsReceived
const bids = _bidsReceived
.filter(adUnitsFilter.bind(this, adUnitCodes))
.reduce(groupByPlacement, {})];
_callback.apply($$PREBID_GLOBAL$$, bids);
.reduce(groupByPlacement, {});
_callback.apply($$PREBID_GLOBAL$$, [bids, timedOut]);
} catch (e) {
utils.logError('Error executing bidsBackHandler', null, e);
} finally {
Expand Down
13 changes: 11 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ describe('Unit: Prebid Module', function () {
let xhr;
let adUnits;
let clock;
let bidsBackHandlerStub = sinon.stub();

const BIDDER_CODE = 'sampleBidder';
let bids = [{
Expand Down Expand Up @@ -1140,7 +1141,12 @@ describe('Unit: Prebid Module', function () {
]
}];
let adUnitCodes = ['adUnit-code'];
let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 2000});
let auction = auctionModule.newAuction({
adUnits,
adUnitCodes,
callback: bidsBackHandlerStub,
cbTimeout: 2000
});
let createAuctionStub = sinon.stub(auctionModule, 'newAuction');
createAuctionStub.returns(auction);
});
Expand Down Expand Up @@ -1169,7 +1175,7 @@ describe('Unit: Prebid Module', function () {

clock = sinon.useFakeTimers();
let requestObj = {
bidsBackHandler: function bidsBackHandlerCallback() {},
bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach
timeout: 2000,
adUnits: adUnits
};
Expand All @@ -1181,6 +1187,9 @@ describe('Unit: Prebid Module', function () {

clock.tick(1);
assert.ok(logMessageSpy.calledWith(sinon.match(re)), 'executeCallback called');

expect(bidsBackHandlerStub.getCall(0).args[1]).to.equal(true,
'bidsBackHandler should be called with timedOut=true');
});
})

Expand Down