Skip to content

Commit

Permalink
clean(openxBidderAdaptor): converted video size to numbers from strin…
Browse files Browse the repository at this point in the history
…gs to keep consistency between banner and video.
  • Loading branch information
Jimmy Tu committed May 7, 2020
1 parent 2621343 commit bc4217b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function generateVideoParameters(bid, bidderRequest) {
function createVideoBidResponses(response, {bid, startTime}) {
let bidResponses = [];

if (response !== undefined && response.vastUrl !== '' && response.pub_rev !== '') {
if (response !== undefined && response.vastUrl !== '' && response.pub_rev > 0) {
let vastQueryParams = utils.parseUrl(response.vastUrl).search || {};
let bidResponse = {};
bidResponse.requestId = bid.bidId;
Expand All @@ -431,9 +431,9 @@ function createVideoBidResponses(response, {bid, startTime}) {
// true is net, false is gross
bidResponse.netRevenue = true;
bidResponse.currency = response.currency;
bidResponse.cpm = Number(response.pub_rev) / 1000;
bidResponse.width = response.width;
bidResponse.height = response.height;
bidResponse.cpm = parseInt(response.pub_rev, 10) / 1000;
bidResponse.width = parseInt(response.width, 10);
bidResponse.height = parseInt(response.height, 10);
bidResponse.creativeId = response.adid;
bidResponse.vastUrl = response.vastUrl;
bidResponse.mediaType = VIDEO;
Expand Down
35 changes: 17 additions & 18 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ describe('OpenxAdapter', function () {
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e'
}
};
mockBidderRequest = {refererInfo: {}};
});

Expand Down Expand Up @@ -1587,32 +1587,31 @@ describe('OpenxAdapter', function () {
payload: {'bid': bidsWithMediaType[0], 'startTime': new Date()}
};
const bidResponse = {
'pub_rev': '1',
'pub_rev': '1000',
'width': '640',
'height': '480',
'adid': '5678',
'vastUrl': 'https://testvast.com/vastpath?colo=https://test-colo.com&ph=test-ph&ts=test-ts',
'currency': 'AUD',
'vastUrl': 'https://testvast.com',
'pixels': 'https://testpixels.net'
};

it('should return correct bid response with MediaTypes', function () {
const expectedResponse = [
{
'requestId': '30b31c1838de1e',
'cpm': 1,
'width': '640',
'height': '480',
'mediaType': 'video',
'creativeId': '5678',
'vastUrl': 'https://testvast.com',
'ttl': 300,
'netRevenue': true,
'currency': 'USD'
}
];
const expectedResponse = {
'requestId': '30b31c1838de1e',
'cpm': 1,
'width': 640,
'height': 480,
'mediaType': 'video',
'creativeId': '5678',
'vastUrl': 'https://testvast.com',
'ttl': 300,
'netRevenue': true,
'currency': 'AUD'
};

const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaTypes);
expect(JSON.stringify(Object.keys(result[0]).sort())).to.eql(JSON.stringify(Object.keys(expectedResponse[0]).sort()));
expect(result[0]).to.eql(expectedResponse);
});

it('should return correct bid response with MediaType', function () {
Expand Down

0 comments on commit bc4217b

Please sign in to comment.