Skip to content

Commit

Permalink
[1.x] Populate crid with values from demand if present (prebid#2424)
Browse files Browse the repository at this point in the history
* fix sovrn dealid

* send 'iv' param if present

* `page` field in `site` object sends full url

* Enhance location detection within util function.

* fix func call

* fix tagid var type

* add test for converting tagid to string

* CR

* Reorg gettopwindowlocation util & add tests.

* lint fixes

* search param is string in window location objects

* set creativeId to crid if present in response
  • Loading branch information
aprakash-sovrn authored and snapwich committed May 1, 2018
1 parent 77d0e06 commit d28c4a8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const spec = {
cpm: parseFloat(sovrnBid.price),
width: parseInt(sovrnBid.w),
height: parseInt(sovrnBid.h),
creativeId: sovrnBid.id,
creativeId: sovrnBid.crid || sovrnBid.id,
dealId: sovrnBid.dealid || null,
currency: 'USD',
netRevenue: true,
Expand Down
58 changes: 41 additions & 17 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,54 @@ describe('sovrnBidAdapter', function() {
});

describe('interpretResponse', () => {
let response = {
body: {
'id': '37386aade21a71',
'seatbid': [{
'bid': [{
'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28',
'impid': '263c448586f5a1',
'price': 0.45882675,
'nurl': '<!-- NURL -->',
'adm': '<!-- Creative -->',
'h': 90,
'w': 728
let response;
beforeEach(() => {
response = {
body: {
'id': '37386aade21a71',
'seatbid': [{
'bid': [{
'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28',
'crid': 'creativelycreatedcreativecreative',
'impid': '263c448586f5a1',
'price': 0.45882675,
'nurl': '<!-- NURL -->',
'adm': '<!-- Creative -->',
'h': 90,
'w': 728
}]
}]
}]
}
};
}
};
});

it('should get the correct bid response', () => {
let expectedResponse = [{
'requestId': '263c448586f5a1',
'cpm': 0.45882675,
'width': 728,
'height': 90,
'creativeId': 'a_403370_332fdb9b064040ddbec05891bd13ab28',
'creativeId': 'creativelycreatedcreativecreative',
'dealId': null,
'currency': 'USD',
'netRevenue': true,
'mediaType': 'banner',
'ad': decodeURIComponent(`<!-- Creative --><img src=<!-- NURL -->>`),
'ttl': 60000
}];

let result = spec.interpretResponse(response);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
});

it('crid should default to the bid id if not on the response', () => {
delete response.body.seatbid[0].bid[0].crid;
let expectedResponse = [{
'requestId': '263c448586f5a1',
'cpm': 0.45882675,
'width': 728,
'height': 90,
'creativeId': response.body.seatbid[0].bid[0].id,
'dealId': null,
'currency': 'USD',
'netRevenue': true,
Expand All @@ -150,7 +174,7 @@ describe('sovrnBidAdapter', function() {
'cpm': 0.45882675,
'width': 728,
'height': 90,
'creativeId': 'a_403370_332fdb9b064040ddbec05891bd13ab28',
'creativeId': 'creativelycreatedcreativecreative',
'dealId': 'baking',
'currency': 'USD',
'netRevenue': true,
Expand Down

0 comments on commit d28c4a8

Please sign in to comment.