Skip to content

Commit

Permalink
prebid#3197 Added unit test to check if callback is called when bidRe…
Browse files Browse the repository at this point in the history
…quests is empty
  • Loading branch information
Dmitry Fedotov committed Oct 23, 2018
1 parent 535ea0d commit 83228f7
Showing 1 changed file with 33 additions and 0 deletions.
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

0 comments on commit 83228f7

Please sign in to comment.