Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}<img src="${sovrnBid.nurl}">`)
} else {
if (sovrnBid.mtype == 2) {
bid.vastXml = decodeURIComponent(sovrnBid.adm)
} else {
bid.ad = sovrnBid.nurl ? decodeURIComponent(`${sovrnBid.adm}<img src="${sovrnBid.nurl}">`) : decodeURIComponent(sovrnBid.adm)
}

return bid
Expand Down
74 changes: 71 additions & 3 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,8 @@ describe('sovrnBidAdapter', function() {
nurl: '',
adm: '<VAST version="4.2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.iab.com/VAST">key%3Dvalue</VAST>',
h: 480,
w: 640
w: 640,
mtype: 2
}
const bannerBid = {
id: 'a_403370_332fdb9b064040ddbec05891bd13ab28',
Expand All @@ -773,7 +774,8 @@ describe('sovrnBidAdapter', function() {
nurl: '<!-- NURL -->',
adm: '<!-- Creative -->',
h: 90,
w: 728
w: 728,
mtype: 1
}

beforeEach(function () {
Expand All @@ -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(`<!-- Creative -->`)
}

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(`<!-- Creative --><img src=<!-- NURL -->>`)
}

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',
Expand Down Expand Up @@ -1072,7 +1139,8 @@ describe('sovrnBidAdapter', function() {
nurl: '',
adm: bidAdm,
h: 480,
w: 640
w: 640,
mtype: 2
}]
}]
}
Expand Down
Loading