diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index 6d9aa5d159c..dfabf4eef55 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -2,12 +2,15 @@ import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; const BIDDER_CODE = 'improvedigital'; +const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; export const spec = { - version: '6.1.0', + version: '7.0.0', code: BIDDER_CODE, + gvlid: 253, aliases: ['id'], supportedMediaTypes: [BANNER, NATIVE, VIDEO], @@ -61,7 +64,7 @@ export const spec = { if (requestObj.errors && requestObj.errors.length > 0) { utils.logError('ID WARNING 0x01'); } - + requestObj.requests.forEach(request => request.bidderRequest = bidderRequest); return requestObj.requests; }, @@ -71,7 +74,7 @@ export const spec = { * @param {*} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function (serverResponse, bidRequest) { + interpretResponse: function (serverResponse, {bidderRequest}) { const bids = []; utils._each(serverResponse.body.bid, function (bidObject) { if (!bidObject.price || bidObject.price === null || @@ -79,7 +82,7 @@ export const spec = { (!bidObject.adm && !bidObject.native)) { return; } - + const bidRequest = utils.getBidRequest(bidObject.id, [bidderRequest]); const bid = {}; if (bidObject.native) { @@ -94,6 +97,14 @@ export const spec = { } else if (bidObject.ad_type && bidObject.ad_type === 'video') { bid.vastXml = bidObject.adm; bid.mediaType = VIDEO; + if (isOutstreamVideo(bidRequest)) { + bid.adResponse = { + content: bid.vastXml, + height: bidObject.h, + width: bidObject.w + }; + bid.renderer = createRenderer(bidRequest); + } } else { // Banner let nurl = ''; @@ -136,10 +147,6 @@ export const spec = { if (!bid.width || !bid.height) { bid.width = 1; bid.height = 1; - if (bidRequest.sizes) { - bid.width = bidRequest.sizes[0][0]; - bid.height = bidRequest.sizes[0][1]; - } } bids.push(bid); @@ -180,6 +187,50 @@ function isInstreamVideo(bid) { return bid.mediaType === 'video' || (videoMediaType && context !== 'outstream'); } +function isOutstreamVideo(bid) { + const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video'); + const context = utils.deepAccess(bid, 'mediaTypes.video.context'); + return videoMediaType && context === 'outstream'; +} + +function outstreamRender(bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [bid.width, bid.height], + width: bid.width, + height: bid.height, + targetId: bid.adUnitCode, + adResponse: bid.adResponse, + rendererOptions: { + showBigPlayButton: false, + showProgressBar: 'bar', + showVolume: false, + allowFullscreen: true, + skippable: false, + } + }); + }); +} + +function createRenderer(bidRequest) { + const renderer = Renderer.install({ + id: bidRequest.adUnitCode, + url: RENDERER_URL, + loaded: false, + config: { + player_width: bidRequest.mediaTypes.video.playerSize[0][0], + player_height: bidRequest.mediaTypes.video.playerSize[0][1] + }, + adUnitCode: bidRequest.adUnitCode + }); + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + function getNormalizedBidRequest(bid) { let adUnitId = utils.getBidIdParameter('adUnitCode', bid) || null; let placementId = utils.getBidIdParameter('placementId', bid.params) || null; @@ -217,7 +268,7 @@ function getNormalizedBidRequest(bid) { normalizedBidRequest.keyValues = keyValues; } - if (config.getConfig('improvedigital.usePrebidSizes') === true && !isInstreamVideo(bid) && bid.sizes && bid.sizes.length > 0) { + if (config.getConfig('improvedigital.usePrebidSizes') === true && !isInstreamVideo(bid) && !isOutstreamVideo(bid) && bid.sizes && bid.sizes.length > 0) { normalizedBidRequest.format = bid.sizes; } else if (singleSizeFilter && singleSizeFilter.w && singleSizeFilter.h) { normalizedBidRequest.size = {}; diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 676f6ab0fd0..1466b509c54 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -1,10 +1,10 @@ import { expect } from 'chai'; import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter.js'; import { config } from 'src/config.js'; -import { userSync } from 'src/userSync.js'; +import * as utils from 'src/utils.js'; describe('Improve Digital Adapter Tests', function () { - let idClient = new ImproveDigitalAdServerJSClient('hb'); + const idClient = new ImproveDigitalAdServerJSClient('hb'); const METHOD = 'GET'; const URL = 'https://ice.360yield.com/hb'; @@ -20,9 +20,41 @@ describe('Improve Digital Adapter Tests', function () { bidId: '33e9500b21129f', bidderRequestId: '2772c1e566670b', auctionId: '192721e36a0239', + mediaTypes: { + banner: { + sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] + } + }, sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] }; + const instreamBidRequest = utils.deepClone(simpleBidRequest); + instreamBidRequest.mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480] + } + }; + + const outstreamBidRequest = utils.deepClone(simpleBidRequest); + outstreamBidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }; + + const multiFormatBidRequest = utils.deepClone(simpleBidRequest); + multiFormatBidRequest.mediaTypes = { + banner: { + sizes: [[300, 250], [160, 600], ['blah', 150], [-1, 300], [300, -5]] + }, + video: { + context: 'outstream', + playerSize: [640, 480] + } + }; + const simpleSmartTagBidRequest = { bidder: 'improvedigital', bidId: '1a2b3c', @@ -33,7 +65,24 @@ describe('Improve Digital Adapter Tests', function () { } }; + const bidderRequest = { + bids: [simpleBidRequest] + }; + + const instreamBidderRequest = { + bids: [instreamBidRequest] + }; + + const outstreamBidderRequest = { + bids: [outstreamBidRequest] + }; + + const multiFormatBidderRequest = { + bids: [multiFormatBidRequest] + }; + const bidderRequestGdpr = { + bids: [simpleBidRequest], gdprConsent: { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', vendorData: {}, @@ -42,6 +91,7 @@ describe('Improve Digital Adapter Tests', function () { }; const bidderRequestReferrer = { + bids: [simpleBidRequest], refererInfo: { referer: 'https://blah.com/test.html', }, @@ -53,12 +103,12 @@ describe('Improve Digital Adapter Tests', function () { }); it('should return false when no bid.params', function () { - let bid = {}; + const bid = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); it('should return false when both placementId and placementKey + publisherId are missing', function () { - let bid = { 'params': {} }; + const bid = { 'params': {} }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -78,25 +128,51 @@ describe('Improve Digital Adapter Tests', function () { }); it('should return true when placementId is passed', function () { - let bid = { 'params': {} }; expect(spec.isBidRequestValid(simpleBidRequest)).to.equal(true); }); it('should return true when both placementKey and publisherId are passed', function () { - let bid = { 'params': {} }; expect(spec.isBidRequestValid(simpleSmartTagBidRequest)).to.equal(true); }); }); describe('buildRequests', function () { it('should make a well-formed request objects', function () { - const requests = spec.buildRequests([simpleBidRequest]); + const requests = spec.buildRequests([simpleBidRequest], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(1); const request = requests[0]; expect(request.method).to.equal(METHOD); expect(request.url).to.equal(URL); + expect(request.bidderRequest).to.deep.equal(bidderRequest); + expect(request.data.substring(0, PARAM_PREFIX.length)).to.equal(PARAM_PREFIX); + + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request).to.be.an('object'); + expect(params.bid_request.id).to.be.a('string'); + expect(params.bid_request.version).to.equal(`${spec.version}-${idClient.CONSTANTS.CLIENT_VERSION}`); + expect(params.bid_request.gdpr).to.not.exist; + expect(params.bid_request.us_privacy).to.not.exist; + expect(params.bid_request.imp).to.deep.equal([ + { + id: '33e9500b21129f', + pid: 1053688, + tid: 'f183e871-fbed-45f0-a427-c8a63c4c01eb', + banner: {} + } + ]); + }); + + it('should make a well-formed request object for multi-format ad unit', function () { + const requests = spec.buildRequests([multiFormatBidRequest], multiFormatBidderRequest); + expect(requests).to.be.an('array'); + expect(requests.length).to.equal(1); + + const request = requests[0]; + expect(request.method).to.equal(METHOD); + expect(request.url).to.equal(URL); + expect(request.bidderRequest).to.deep.equal(multiFormatBidderRequest); expect(request.data.substring(0, PARAM_PREFIX.length)).to.equal(PARAM_PREFIX); const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); @@ -116,33 +192,33 @@ describe('Improve Digital Adapter Tests', function () { }); it('should set placementKey and publisherId for smart tags', function () { - const requests = spec.buildRequests([simpleSmartTagBidRequest]); + const requests = spec.buildRequests([simpleSmartTagBidRequest], bidderRequest); const params = JSON.parse(decodeURIComponent(requests[0].data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].pubid).to.equal(1032); expect(params.bid_request.imp[0].pkey).to.equal('data_team_test_hb_smoke_test'); }); it('should add keyValues', function () { - let bidRequest = Object.assign({}, simpleBidRequest); + const bidRequest = Object.assign({}, simpleBidRequest); const keyValues = { testKey: [ 'testValue' ] }; bidRequest.params.keyValues = keyValues; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].kvw).to.deep.equal(keyValues); }); it('should add single size filter', function () { - let bidRequest = Object.assign({}, simpleBidRequest); + const bidRequest = Object.assign({}, simpleBidRequest); const size = { w: 800, h: 600 }; bidRequest.params.size = size; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal(size); // When single size filter is set, format shouldn't be populated. This @@ -153,7 +229,7 @@ describe('Improve Digital Adapter Tests', function () { it('should add currency', function () { const bidRequest = Object.assign({}, simpleBidRequest); const getConfigStub = sinon.stub(config, 'getConfig').returns('JPY'); - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].currency).to.equal('JPY'); getConfigStub.restore(); @@ -161,14 +237,14 @@ describe('Improve Digital Adapter Tests', function () { it('should add bid floor', function () { const bidRequest = Object.assign({}, simpleBidRequest); - let request = spec.buildRequests([bidRequest])[0]; + let request = spec.buildRequests([bidRequest], bidderRequest)[0]; let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); // Floor price currency shouldn't be populated without a floor price expect(params.bid_request.imp[0].bidfloorcur).to.not.exist; // Default floor price currency bidRequest.params.bidFloor = 0.05; - request = spec.buildRequests([bidRequest])[0]; + request = spec.buildRequests([bidRequest], bidderRequest)[0]; params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].bidfloor).to.equal(0.05); expect(params.bid_request.imp[0].bidfloorcur).to.equal('USD'); @@ -205,7 +281,7 @@ describe('Improve Digital Adapter Tests', function () { it('should add ad type for instream video', function () { let bidRequest = Object.assign({}, simpleBidRequest); bidRequest.mediaType = 'video'; - let request = spec.buildRequests([bidRequest])[0]; + let request = spec.buildRequests([bidRequest], bidderRequest)[0]; let params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); @@ -216,38 +292,48 @@ describe('Improve Digital Adapter Tests', function () { playerSize: [640, 480] } }; - request = spec.buildRequests([bidRequest])[0]; + request = spec.buildRequests([bidRequest], bidderRequest)[0]; params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].ad_types).to.deep.equal(['video']); }); + it('should not set ad type for outstream video', function() { + const request = spec.buildRequests([outstreamBidRequest])[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.not.exist; + }); + + it('should not set ad type for multi-format bids', function() { + const request = spec.buildRequests([multiFormatBidRequest], bidderRequest)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].ad_types).to.not.exist; + }); + it('should not set Prebid sizes in bid request for instream video', function () { const getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const bidRequest = Object.assign({}, simpleBidRequest); - bidRequest.mediaTypes = { - video: { - context: 'instream', - playerSize: [640, 480] - } - }; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([instreamBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner.format).to.not.exist; getConfigStub.restore(); }); - it('should not set ad type for outstream video', function() { - const bidRequest = Object.assign({}, simpleBidRequest); - bidRequest.mediaTypes = { - video: { - context: 'outstream', - playerSize: [640, 480] - } - }; - const request = spec.buildRequests([bidRequest])[0]; + it('should not set Prebid sizes in bid request for outstream video', function () { + const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); + const request = spec.buildRequests([outstreamBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); - expect(params.bid_request.imp[0].ad_types).to.not.exist; + expect(params.bid_request.imp[0].banner.format).to.not.exist; + getConfigStub.restore(); + }); + + it('should not set Prebid sizes in multi-format bid request', function () { + const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); + const request = spec.buildRequests([multiFormatBidRequest], bidderRequest)[0]; + const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); + expect(params.bid_request.imp[0].banner.format).to.not.exist; + getConfigStub.restore(); }); it('should add schain', function () { @@ -263,9 +349,11 @@ describe('Improve Digital Adapter Tests', function () { const requests = spec.buildRequests([ simpleBidRequest, simpleSmartTagBidRequest - ]); + ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(2); + expect(requests[0].bidderRequest).to.deep.equal(bidderRequest); + expect(requests[1].bidderRequest).to.deep.equal(bidderRequest); }); it('should return one request in a single request mode', function () { @@ -274,7 +362,7 @@ describe('Improve Digital Adapter Tests', function () { const requests = spec.buildRequests([ simpleBidRequest, simpleSmartTagBidRequest - ]); + ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(1); getConfigStub.restore(); @@ -283,7 +371,7 @@ describe('Improve Digital Adapter Tests', function () { it('should set Prebid sizes in bid request', function () { const getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const request = spec.buildRequests([simpleBidRequest])[0]; + const request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal({ format: [ @@ -303,7 +391,7 @@ describe('Improve Digital Adapter Tests', function () { h: 600 }; bidRequest.params.size = size; - const request = spec.buildRequests([bidRequest])[0]; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const params = JSON.parse(decodeURIComponent(request.data.substring(PARAM_PREFIX.length))); expect(params.bid_request.imp[0].banner).to.deep.equal({ format: [ @@ -555,7 +643,7 @@ describe('Improve Digital Adapter Tests', function () { ]; describe('interpretResponse', function () { - let expectedBid = [ + const expectedBid = [ { 'ad': '', 'adId': '33e9500b21129f', @@ -571,7 +659,7 @@ describe('Improve Digital Adapter Tests', function () { } ]; - let expectedTwoBids = [ + const expectedTwoBids = [ expectedBid[0], { 'ad': '', @@ -588,7 +676,7 @@ describe('Improve Digital Adapter Tests', function () { } ]; - let expectedBidNative = [ + const expectedBidNative = [ { mediaType: 'native', adId: '33e9500b21129f', @@ -637,7 +725,7 @@ describe('Improve Digital Adapter Tests', function () { } ]; - let expectedBidVideo = [ + const expectedBidInstreamVideo = [ { 'vastXml': '', 'adId': '33e9500b21129f', @@ -653,60 +741,72 @@ describe('Improve Digital Adapter Tests', function () { } ]; - it('should return a well-formed bid', function () { - const bids = spec.interpretResponse(serverResponse); + const expectedBidOutstreamVideo = utils.deepClone(expectedBidInstreamVideo); + expectedBidOutstreamVideo[0].adResponse = { + content: expectedBidOutstreamVideo[0].vastXml, + height: expectedBidOutstreamVideo[0].height, + width: expectedBidOutstreamVideo[0].width + }; + + it('should return a well-formed display bid', function () { + const bids = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(bids).to.deep.equal(expectedBid); + }); + + it('should return a well-formed display bid for multi-format ad unit', function () { + const bids = spec.interpretResponse(serverResponse, {bidderRequest: multiFormatBidderRequest}); expect(bids).to.deep.equal(expectedBid); }); it('should return two bids', function () { - const bids = spec.interpretResponse(serverResponseTwoBids); + const bids = spec.interpretResponse(serverResponseTwoBids, {bidderRequest}); expect(bids).to.deep.equal(expectedTwoBids); }); it('should set dealId correctly', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); let bids; delete response.body.bid[0].lid; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; delete response.body.bid[0].buying_type; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; response.body.bid[0].buying_type = 'classic'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = 268515; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.equal(268515); response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = 'deal_id'; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = [ 'deal_id', 'classic' ]; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.not.exist; response.body.bid[0].lid = [ 268515, 12456, 34567 ]; response.body.bid[0].buying_type = [ 'classic', 'deal_id', 'deal_id' ]; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].dealId).to.equal(12456); }); it('should set currency', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].currency = 'eur'; - const bids = spec.interpretResponse(response); + const bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].currency).to.equal('EUR'); }); @@ -716,41 +816,41 @@ describe('Improve Digital Adapter Tests', function () { // Price missing or 0 response.body.bid[0].price = 0; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); delete response.body.bid[0].price; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); response.body.bid[0].price = null; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); // errorCode present response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].errorCode = undefined; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); // adm and native missing response = JSON.parse(JSON.stringify(serverResponse)); delete response.body.bid[0].adm; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); response.body.bid[0].adm = null; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); expect(bids).to.deep.equal([]); }); it('should set netRevenue', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const response = JSON.parse(JSON.stringify(serverResponse)); response.body.bid[0].isNet = true; - const bids = spec.interpretResponse(response); + const bids = spec.interpretResponse(response, {bidderRequest}); expect(bids[0].netRevenue).to.equal(true); }); // Native ads it('should return a well-formed native ad bid', function () { - let bids = spec.interpretResponse(serverResponseNative); + let bids = spec.interpretResponse(serverResponseNative, {bidderRequest}); expect(bids[0].ortbNative).to.deep.equal(serverResponseNative.body.bid[0].native); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBidNative); @@ -764,15 +864,29 @@ describe('Improve Digital Adapter Tests', function () { 'https://www.mytracker.com/imptracker' ]; expectedBids[0].native.javascriptTrackers = ''; - bids = spec.interpretResponse(response); + bids = spec.interpretResponse(response, {bidderRequest}); delete bids[0].ortbNative; expect(bids).to.deep.equal(expectedBids); }); // Video - it('should return a well-formed video bid', function () { - const bids = spec.interpretResponse(serverResponseVideo); - expect(bids).to.deep.equal(expectedBidVideo); + it('should return a well-formed instream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: instreamBidderRequest}); + expect(bids).to.deep.equal(expectedBidInstreamVideo); + }); + + it('should return a well-formed outstream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: outstreamBidderRequest}); + expect(bids[0].renderer).to.exist; + delete (bids[0].renderer); + expect(bids).to.deep.equal(expectedBidOutstreamVideo); + }); + + it('should return a well-formed outstream video bid for multi-format ad unit', function () { + const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: multiFormatBidderRequest}); + expect(bids[0].renderer).to.exist; + delete (bids[0].renderer); + expect(bids).to.deep.equal(expectedBidOutstreamVideo); }); });