Skip to content

Commit 4e8436d

Browse files
committed
updated targeting_spec to test bidLimit
1 parent c4c7224 commit 4e8436d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/spec/unit/core/targeting_spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,58 @@ describe('targeting tests', function () {
330330
expect(logWarnStub.calledTwice).to.be.true;
331331
expect(logErrorStub.calledOnce).to.be.true;
332332
});
333+
334+
describe('when bidLimit is present in setConfig', function () {
335+
let bid4;
336+
337+
beforeEach(function() {
338+
bid4 = utils.deepClone(bid1);
339+
bid4.adserverTargeting['hb_bidder'] = bid4.bidder = bid4.bidderCode = 'appnexus';
340+
bid4.cpm = 2.25;
341+
enableSendAllBids = true;
342+
343+
bidsReceived.push(bid4);
344+
});
345+
346+
it('selects the top n number of bids when enableSendAllBids is true and and bitLimit is set', function () {
347+
config.setConfig({
348+
sendBidsControl: {
349+
bidLimit: 1
350+
}
351+
});
352+
353+
const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
354+
let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1)
355+
356+
expect(limitedBids.length).to.equal(1);
357+
});
358+
359+
it('sends all bids when enableSendAllBids is true and and bitLimit is above total number of bids received', function () {
360+
config.setConfig({
361+
sendBidsControl: {
362+
bidLimit: 50
363+
}
364+
});
365+
366+
const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
367+
let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1)
368+
369+
expect(limitedBids.length).to.equal(2);
370+
});
371+
372+
it('Sends all bids when enableSendAllBids is true and and bitLimit is set to 0', function () {
373+
config.setConfig({
374+
sendBidsControl: {
375+
bidLimit: 0
376+
}
377+
});
378+
379+
const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
380+
let limitedBids = Object.keys(targeting['/123456/header-bid-tag-0']).filter(key => key.indexOf(CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_') != -1)
381+
382+
expect(limitedBids.length).to.equal(2);
383+
});
384+
});
333385

334386
describe('targetingControls.alwaysIncludeDeals', function () {
335387
let bid4;

0 commit comments

Comments
 (0)