Skip to content

Commit

Permalink
includes unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
karimMourra committed Nov 8, 2023
1 parent 8002967 commit 7b5b8fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 7b5b8fa

Please sign in to comment.