Skip to content

Commit

Permalink
there were some changes to the bid factory after our initial release …
Browse files Browse the repository at this point in the history
…that we didn't account for. Changing adapter to account for response body and required params.
  • Loading branch information
Mike Groh committed Dec 5, 2017
1 parent 40444f7 commit 324d157
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions modules/trionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export const spec = {
var bid = {};
var bidResponses = [];
var bidRequest = request.bidRequest;
var responseBody = trionResponseObj ? trionResponseObj.body : {};

if (trionResponseObj && trionResponseObj.bidId && bidRequest) {
var result = trionResponseObj.result;
if (responseBody && responseBody.bidId && bidRequest) {
var result = responseBody.result;

if (result && result.cpm && result.placeBid && result.ad) {
var cpm = parseInt(result.cpm, 10) / 100;
Expand All @@ -45,6 +46,10 @@ export const spec = {
bid.ad = result.ad;
bid.width = result.width;
bid.height = result.height;
bid.ttl = result.ttl;
bid.creativeId = result.creativeId;
bid.currency = result.currency;
bid.netRevenue = result.netRevenue;
bidResponses.push(bid);
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/spec/modules/trionBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Trion adapter tests', () => {

it('when place bid is returned as false', () => {
TRION_BID_RESPONSE.result.placeBid = false;
let response = spec.interpretResponse(TRION_BID_RESPONSE, {bidRequest: TRION_BID});
let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID});

expect(response).to.deep.equal([]);

Expand All @@ -136,14 +136,14 @@ describe('Trion adapter tests', () => {

it('when no cpm is in the response', () => {
TRION_BID_RESPONSE.result.cpm = 0;
let response = spec.interpretResponse(TRION_BID_RESPONSE, {bidRequest: TRION_BID});
let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID});
expect(response).to.deep.equal([]);
TRION_BID_RESPONSE.result.cpm = 1;
});

it('when no ad is in the response', () => {
TRION_BID_RESPONSE.result.ad = null;
let response = spec.interpretResponse(TRION_BID_RESPONSE, {bidRequest: TRION_BID});
let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID});
expect(response).to.deep.equal([]);
TRION_BID_RESPONSE.result.ad = 'test';
});
Expand All @@ -153,7 +153,7 @@ describe('Trion adapter tests', () => {
let bidHeight = '2';
TRION_BID_RESPONSE.result.width = bidWidth;
TRION_BID_RESPONSE.result.height = bidHeight;
let response = spec.interpretResponse(TRION_BID_RESPONSE, {bidRequest: TRION_BID});
let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID});
expect(response[0].width).to.equal(bidWidth);
expect(response[0].height).to.equal(bidHeight);
TRION_BID_RESPONSE.result.width = '300';
Expand All @@ -163,7 +163,7 @@ describe('Trion adapter tests', () => {
it('cpm is properly set and transformed to cents', () => {
let bidCpm = 2;
TRION_BID_RESPONSE.result.cpm = bidCpm * 100;
let response = spec.interpretResponse(TRION_BID_RESPONSE, {bidRequest: TRION_BID});
let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID});
expect(response[0].cpm).to.equal(bidCpm);
TRION_BID_RESPONSE.result.cpm = 100;
});
Expand Down

0 comments on commit 324d157

Please sign in to comment.