diff --git a/src/auction.js b/src/auction.js index b913f792d2b..da22c05c628 100644 --- a/src/auction.js +++ b/src/auction.js @@ -201,6 +201,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, diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 61e26891bac..a03339c76b3 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -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;