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

Fixes #3197 - call auctionDone() when 'No valid bid requests returned for auction' #3198

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
1 change: 1 addition & 0 deletions src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels})

if (bidRequests.length < 1) {
utils.logWarn('No valid bid requests returned for auction');
auctionDone();
} else {
let call = {
bidRequests,
Expand Down
33 changes: 33 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,39 @@ describe('Unit: Prebid Module', function () {
});
})

describe('requestBids', function () {
let sandbox;
beforeEach(function () {
sandbox = sinon.sandbox.create();
});
afterEach(function () {
sandbox.restore();
});
describe('bidRequests is empty', function () {
it('should log warning message and execute callback if bidRequests is empty', function () {
let bidsBackHandler = function bidsBackHandlerCallback() {};
let spyExecuteCallback = sinon.spy(bidsBackHandler);
let logWarnSpy = sandbox.spy(utils, 'logWarn');

$$PREBID_GLOBAL$$.requestBids({
adUnits: [
{
code: 'test1',
bids: [],
}, {
code: 'test2',
bids: [],
}
],
bidsBackHandler: spyExecuteCallback
});

assert.ok(logWarnSpy.calledWith('No valid bid requests returned for auction'), 'expected warning message was logged');
assert.ok(spyExecuteCallback.calledOnce, 'callback executed when bidRequests is empty');
});
});
});

describe('requestBids', function () {
let xhr;
let requests;
Expand Down