diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 15bcca50a13..0400aa46ecf 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,7 +1,6 @@ import { registerBidder } from 'src/adapters/bidderFactory'; -import { getTopWindowLocation, parseSizesInput, logError, generateUUID, deepAccess, isEmpty } from '../src/utils'; +import { getTopWindowLocation, parseSizesInput, logError, generateUUID, isEmpty } from '../src/utils'; import { BANNER, VIDEO } from '../src/mediaTypes'; -import find from 'core-js/library/fn/array/find'; import { config } from '../src/config'; const BIDDER_CODE = 'sonobi'; @@ -104,12 +103,10 @@ export const spec = { } Object.keys(bidResponse.slots).forEach(slot => { + const bid = bidResponse.slots[slot]; const bidId = _getBidIdFromTrinityKey(slot); - const bidRequest = find(bidderRequests, bidReqest => bidReqest.bidId === bidId); - const videoMediaType = deepAccess(bidRequest, 'mediaTypes.video'); - const mediaType = bidRequest.mediaType || (videoMediaType ? 'video' : null); + const mediaType = (bid.sbi_ct === 'video') ? 'video' : null; const createCreative = _creative(mediaType); - const bid = bidResponse.slots[slot]; if (bid.sbi_aid && bid.sbi_mouse && bid.sbi_size) { const [ width = 1, @@ -132,8 +129,7 @@ export const spec = { bids.dealId = bid.sbi_dozer; } - const creativeType = bid.sbi_ct; - if (creativeType && (creativeType === 'video' || creativeType === 'outstream')) { + if (mediaType === 'video') { bids.mediaType = 'video'; bids.vastUrl = createCreative(bidResponse.sbi_dc, bid.sbi_aid); delete bids.ad; diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 69138c063c9..43b35c7d961 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -242,8 +242,7 @@ describe('SonobiBidAdapter', function () { }, 'adUnitCode': 'adunit-code-2', 'sizes': [[120, 600], [300, 600], [160, 600]], - 'bidId': '30b31c1838de1e', - 'mediaType': 'video' + 'bidId': '30b31c1838de1e' }, { 'bidder': 'sonobi', @@ -274,6 +273,14 @@ describe('SonobiBidAdapter', function () { 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.25, 'sbi_dozer': 'dozerkey', + 'sbi_ct': 'video' + }, + '/7780971/sparks_prebid_LB_OUTSTREAM|30b31c1838de1g': { + 'sbi_size': '300x600', + 'sbi_apoc': 'remnant', + 'sbi_crid': '1234abcd', + 'sbi_aid': '30292e432662bd5f86d90774b944b038', + 'sbi_mouse': 1.07, }, '/7780971/sparks_prebid_LB|30b31c1838de1g': {}, }, @@ -313,7 +320,19 @@ describe('SonobiBidAdapter', function () { 'currency': 'USD', 'dealId': 'dozerkey', 'aid': '30292e432662bd5f86d90774b944b038' - } + }, + { + 'requestId': '30b31c1838de1g', + 'cpm': 1.07, + 'width': 300, + 'height': 600, + 'ad': ``, + 'ttl': 500, + 'creativeId': '1234abcd', + 'netRevenue': true, + 'currency': 'USD', + 'aid': '30292e432662bd5f86d90774b944b038' + }, ]; it('should map bidResponse to prebidResponse', function () { @@ -321,14 +340,22 @@ describe('SonobiBidAdapter', function () { response.forEach((resp, i) => { expect(resp.requestId).to.equal(prebidResponse[i].requestId); expect(resp.cpm).to.equal(prebidResponse[i].cpm); - expect(resp.width).to.equal(prebidResponse[i].width); - expect(resp.height).to.equal(prebidResponse[i].height); + expect(resp.ttl).to.equal(prebidResponse[i].ttl); expect(resp.creativeId).to.equal(prebidResponse[i].creativeId); expect(resp.netRevenue).to.equal(prebidResponse[i].netRevenue); expect(resp.currency).to.equal(prebidResponse[i].currency); expect(resp.aid).to.equal(prebidResponse[i].aid); - expect(resp.ad.indexOf('localhost')).to.be.greaterThan(0); + if (resp.mediaType === 'video') { + expect(resp.vastUrl.indexOf('vast.xml')).to.be.greaterThan(0); + expect(resp.ad).to.be.undefined; + expect(resp.width).to.be.undefined; + expect(resp.height).to.be.undefined; + } else { + expect(resp.ad.indexOf('localhost')).to.be.greaterThan(0); + expect(resp.width).to.equal(prebidResponse[i].width); + expect(resp.height).to.equal(prebidResponse[i].height); + } }); }); });