diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 49d7924537f..56f51ccdebb 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -234,15 +234,15 @@ export const spec = { dealId: sovrnBid.dealid || null, currency: 'USD', netRevenue: true, - mediaType: sovrnBid.nurl ? BANNER : VIDEO, + mediaType: sovrnBid.mtype == 2 ? VIDEO : BANNER, ttl: sovrnBid.ext?.ttl || 90, meta: { advertiserDomains: sovrnBid && sovrnBid.adomain ? sovrnBid.adomain : [] } } - if (sovrnBid.nurl) { - bid.ad = decodeURIComponent(`${sovrnBid.adm}`) - } else { + if (sovrnBid.mtype == 2) { bid.vastXml = decodeURIComponent(sovrnBid.adm) + } else { + bid.ad = sovrnBid.nurl ? decodeURIComponent(`${sovrnBid.adm}`) : decodeURIComponent(sovrnBid.adm) } return bid diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 05d18a0bb98..3f5a1e52cda 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -763,7 +763,8 @@ describe('sovrnBidAdapter', function() { nurl: '', adm: 'key%3Dvalue', h: 480, - w: 640 + w: 640, + mtype: 2 } const bannerBid = { id: 'a_403370_332fdb9b064040ddbec05891bd13ab28', @@ -773,7 +774,8 @@ describe('sovrnBidAdapter', function() { nurl: '', adm: '', h: 90, - w: 728 + w: 728, + mtype: 1 } beforeEach(function () { @@ -789,6 +791,71 @@ describe('sovrnBidAdapter', function() { } }) + it('Should return the bid response of correct type when nurl is missing', function () { + const expectedResponse = { + requestId: '263c448586f5a1', + cpm: 0.45882675, + width: 728, + height: 90, + creativeId: 'creativelycreatedcreativecreative', + dealId: null, + currency: 'USD', + netRevenue: true, + mediaType: 'banner', + ttl: 60000, + meta: { advertiserDomains: [] }, + ad: decodeURIComponent(``) + } + + response = { + body: { + id: '37386aade21a71', + seatbid: [{ + bid: [{ + ...bannerBid, + nurl: '' + }] + }] + } + } + + const result = spec.interpretResponse(response) + + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse)) + }) + + it('Should return the bid response of correct type when nurl is present', function () { + const expectedResponse = { + requestId: '263c448586f5a1', + cpm: 0.45882675, + width: 728, + height: 90, + creativeId: 'creativelycreatedcreativecreative', + dealId: null, + currency: 'USD', + netRevenue: true, + mediaType: 'banner', + ttl: 60000, + meta: { advertiserDomains: [] }, + ad: decodeURIComponent(`>`) + } + + response = { + body: { + id: '37386aade21a71', + seatbid: [{ + bid: [{ + ...bannerBid + }] + }] + } + } + + const result = spec.interpretResponse(response) + + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse)) + }) + it('should get the correct bid response', function () { const expectedResponse = { requestId: '263c448586f5a1', @@ -1072,7 +1139,8 @@ describe('sovrnBidAdapter', function() { nurl: '', adm: bidAdm, h: 480, - w: 640 + w: 640, + mtype: 2 }] }] }