Skip to content

Commit c3dde91

Browse files
authored
Merge branch 'master' into DATA-23357
2 parents 9661901 + adaa312 commit c3dde91

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

modules/videoModule/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ export function PbVideo(videoCore_, getConfig_, pbGlobal_, pbEvents_, videoEvent
187187
}
188188

189189
function auctionEnd(auctionResult) {
190-
auctionResult.adUnits.forEach(adUnit => {
191-
if (adUnit.video) {
192-
renderWinningBid(adUnit);
193-
}
194-
});
195190
pbEvents.off(EVENTS.AUCTION_END, auctionEnd);
191+
return Promise.all(
192+
auctionResult.adUnits
193+
.filter(au => au.video)
194+
.map(renderWinningBid)
195+
)
196196
}
197197

198198
function getAdServerConfig(adUnitVideoConfig) {
@@ -212,6 +212,7 @@ export function PbVideo(videoCore_, getConfig_, pbGlobal_, pbEvents_, videoEvent
212212

213213
const adServerConfig = getAdServerConfig(videoConfig);
214214
const winningBid = getWinningBid(adUnitCode);
215+
if (!winningBid) return;
215216

216217
const options = { adUnitCode };
217218

test/spec/modules/videoModule/pbVideo_spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,13 @@ describe('Prebid Video', function () {
246246
}
247247
}
248248
};
249-
const auctionResults = { adUnits: [ expectedAdUnit, {} ] };
249+
let auctionResults;
250250

251251
beforeEach(() => {
252252
gamSubmoduleMock.getAdTagUrl.resetHistory();
253253
videoCoreMock.setAdTagUrl.resetHistory();
254254
adQueueCoordinatorMock.queueAd.resetHistory();
255+
auctionResults = { adUnits: [ expectedAdUnit, {} ] };
255256
});
256257

257258
let beforeBidRequestCallback;
@@ -278,6 +279,20 @@ describe('Prebid Video', function () {
278279
expect(gamSubmoduleMock.getAdTagUrl.getCall(0).args[1]).is.equal(expectedAdTag);
279280
});
280281

282+
it('should not choke when there are no bids', () => {
283+
const pbGlobal = Object.assign({}, pbGlobalMock, {
284+
requestBids,
285+
getHighestCpmBids: () => []
286+
});
287+
auctionResults.adUnits[1].video = {divId: 'other-div'};
288+
pbVideoFactory(null, getConfig, pbGlobal, pbEvents);
289+
beforeBidRequestCallback(() => {}, {});
290+
return auctionEndCallback(auctionResults)
291+
.then(() => {
292+
sinon.assert.notCalled(gamSubmoduleMock.getAdTagUrl);
293+
});
294+
})
295+
281296
it('should load ad tag when ad server returns ad tag', function () {
282297
const expectedAdTag = 'resulting ad tag';
283298
const gamSubmoduleFactory = () => ({

0 commit comments

Comments
 (0)