diff --git a/src/prebid.js b/src/prebid.js index a2aac8562e18..ee2d49b88dc7 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -524,7 +524,7 @@ pbjsInstance.renderAd = hook('async', function (doc, id, options) { const {height, width, ad, mediaType, adUrl, renderer} = bid; // video module - if (FEATURES.VIDEO) { + if (FEATURES.VIDEO && mediaType === 'video') { const adUnit = auctionManager.index.getAdUnit(bid); const videoModule = pbjsInstance.videoModule; const divId = adUnit && adUnit.video && adUnit.video.divId; diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index b458f2482d46..037b66651a5d 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -1482,6 +1482,25 @@ describe('Unit: Prebid Module', function () { $$PREBID_GLOBAL$$.offEvent(CONSTANTS.EVENTS.STALE_RENDER, onStaleEvent); configObj.setConfig({'auctionOptions': {}}); }); + + if (FEATURES.VIDEO) { + it('should render in the Video Module when mediaType is video and the AdUnit includes a video config', function () { + const adUnit = { + video: { + divId: 'playerDivId' + } + }; + sinon.stub(auctionManager.index, 'getAdUnit').callsFake(() => adUnit); + pushBidResponseToAuction({ + mediaType: 'video' + }); + const renderBidSpy = sinon.spy($$PREBID_GLOBAL$$.videoModule, 'renderBid'); + $$PREBID_GLOBAL$$.renderAd(null, bidId); + assert.ok(renderBidSpy.calledOnce, 'videoModule.renderBid should be called when adUnit is configured for Video Module'); + const args = renderBidSpy.getCall(0).args; + assert.ok(args[0] === 'playerDivId', 'divId from adUnit must be passed as an argument'); + }); + } }); describe('requestBids', function () {