Skip to content

Commit

Permalink
add adunit check in case of multi-format
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker committed Feb 5, 2019
1 parent 2b7158f commit 44eb4ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/adpod.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,15 @@ export function callPrebidCacheHook(fn, auctionInstance, bidResponse, afterBidAd
*/
export function checkAdUnitSetupHook(fn, adUnits) {
let goodAdUnits = adUnits.filter(adUnit => {
let videoConfig = adUnit.mediaTypes && adUnit.mediaTypes.video;
let mediaTypes = adUnit.mediaTypes;
let videoConfig = mediaTypes && mediaTypes.video;
if (videoConfig && videoConfig.context === ADPOD) {
// run check to see if other mediaTypes are defined (ie multi-format); reject adUnit if so
if (Object.keys(mediaTypes).length > 1) {
utils.logWarn(`Detected more than one mediaType in adUnitCode: ${adUnit.code} while attempting to define an 'adpod' video adUnit. 'adpod' adUnits cannot be mixed with other mediaTypes. This adUnit will be removed from the auction.`);
return false;
}

let errMsg = `Detected missing or incorrectly setup fields for an adpod adUnit. Please review the following fields of adUnitCode: ${adUnit.code}. This adUnit will be removed from the auction.`;

let playerSize = !!(videoConfig.playerSize && utils.isArrayOfNums(videoConfig.playerSize));
Expand Down
22 changes: 22 additions & 0 deletions test/spec/modules/adpod_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,28 @@ describe('adpod.js', function () {
expect(logWarnStub.calledOnce).to.equal(true);
});

it('removes an incorrectly setup adpod adunit - attempting to use multi-format adUnit', function() {
let adUnits = [{
code: 'multi_test1',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]]
},
video: {
context: 'adpod',
playerSize: [300, 250],
durationRangeSec: [15, 30, 45],
adPodDurationSec: 300
}
}
}];

checkAdUnitSetupHook(callbackFn, adUnits);

expect(results).to.deep.equal([]);
expect(logWarnStub.calledOnce).to.equal(true);
});

it('accepts mixed set of adunits', function() {
let adUnits = [{
code: 'test3',
Expand Down

0 comments on commit 44eb4ec

Please sign in to comment.