diff --git a/src/adRendering.js b/src/adRendering.js index 4b1f2960428..dfed547ee39 100644 --- a/src/adRendering.js +++ b/src/adRendering.js @@ -255,7 +255,7 @@ export function renderAdDirect(doc, adId, options) { if (adData.ad) { doc.write(adData.ad); doc.close(); - emitAdRenderSucceeded({doc, bid, adId: bid.adId}); + emitAdRenderSucceeded({doc, bid, id: bid.adId}); } else { getCreativeRenderer(bid) .then(render => render(adData, { @@ -263,7 +263,7 @@ export function renderAdDirect(doc, adId, options) { mkFrame: createIframe, }, doc.defaultView)) .then( - () => emitAdRenderSucceeded({doc, bid, adId: bid.adId}), + () => emitAdRenderSucceeded({doc, bid, id: bid.adId}), (e) => { fail(e?.reason || AD_RENDER_FAILED_REASON.EXCEPTION, e?.message) e?.stack && logError(e); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index ac8978907a9..e56f3256569 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -28,7 +28,7 @@ import {generateUUID} from '../../../src/utils.js'; import {getCreativeRenderer} from '../../../src/creativeRenderers.js'; import {BID_STATUS, EVENTS, GRANULARITY_OPTIONS, PB_LOCATOR, TARGETING_KEYS} from 'src/constants.js'; import {getBidToRender} from '../../../src/adRendering.js'; -import { setBattrForAdUnit } from '../../../src/prebid.js'; +import {setBattrForAdUnit} from '../../../src/prebid.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -1319,6 +1319,16 @@ describe('Unit: Prebid Module', function () { }); }); + it('should emit AD_RENDER_SUCCEEDED', () => { + sandbox.stub(events, 'emit'); + pushBidResponseToAuction({ + ad: "" + }); + return renderAd(document, bidId).then(() => { + sinon.assert.calledWith(events.emit, EVENTS.AD_RENDER_SUCCEEDED, sinon.match({adId: bidId})); + }); + }); + it('should not render videos', function () { pushBidResponseToAuction({ mediatype: 'video'