Skip to content

Commit

Permalink
feat(video-platform-ids): BID-3468: video support for platform IDs (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
rjvelicaria authored and AdSpacesDevelopers committed Jan 30, 2019
1 parent aeee271 commit 1b12943
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 47 deletions.
4 changes: 3 additions & 1 deletion modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ function buildOXBannerRequest(bids, bidderRequest) {
}

function buildOXVideoRequest(bid, bidderRequest) {
let url = `//${bid.params.delDomain}/v/1.0/avjp`;
let oxVideoParams = generateVideoParameters(bid, bidderRequest);
let url = oxVideoParams.ph
? `//u.openx.net/v/1.0/avjp`
: `//${bid.params.delDomain}/v/1.0/avjp`;
return {
method: 'GET',
url: url,
Expand Down
141 changes: 95 additions & 46 deletions test/spec/modules/openxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,57 +179,106 @@ describe('OpenxAdapter', function () {
});

describe('when request is for a video ad', function () {
const videoBidWithMediaTypes = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};

const videoBidWithMediaType = {
'bidder': 'openx',
'params': {
'unit': '12345678',
'delDomain': 'test-del-domain'
},
'adUnitCode': 'adunit-code',
'mediaType': 'video',
'sizes': [640, 480],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(true);
});
describe('and request config uses mediaTypes', () => {
const videoBidWithMediaTypes = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain'
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(true);
});

it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithMediaTypes);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithMediaTypes);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithMediaTypes]);
expect(request[0].url).to.equal(`//${videoBidWithMediaTypes.params.delDomain}${URLBASEVIDEO}`);
expect(request[0].data.ph).to.be.undefined;
expect(request[0].method).to.equal('GET');
});
});
describe('and request config uses both delDomain and platform', () => {
const videoBidWithDelDomainAndPlatform = {
bidder: 'openx',
params: {
unit: '12345678',
delDomain: 'test-del-domain',
platform: '1cabba9e-cafe-3665-beef-f00f00f00f00',
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480]
}
},
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithDelDomainAndPlatform)).to.equal(true);
});

it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(true);
it('should return false when required params are not passed', function () {
let videoBidWithMediaTypes = Object.assign({}, videoBidWithDelDomainAndPlatform);
videoBidWithMediaTypes.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithDelDomainAndPlatform]);
expect(request[0].url).to.equal(`//u.openx.net${URLBASEVIDEO}`);
expect(request[0].data.ph).to.equal(videoBidWithDelDomainAndPlatform.params.platform);
expect(request[0].method).to.equal('GET');
});
});
describe('and request config uses mediaType', () => {
const videoBidWithMediaType = {
'bidder': 'openx',
'params': {
'unit': '12345678',
'delDomain': 'test-del-domain'
},
'adUnitCode': 'adunit-code',
'mediaType': 'video',
'sizes': [640, 480],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e'
};
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(true);
});

it('should return false when required params are not passed', function () {
let videoBidWithMediaType = Object.assign({}, videoBidWithMediaType);
delete videoBidWithMediaType.params;
videoBidWithMediaType.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false);
it('should return false when required params are not passed', function () {
let videoBidWithMediaType = Object.assign({}, videoBidWithMediaType);
delete videoBidWithMediaType.params;
videoBidWithMediaType.params = {};
expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false);
});
it('should send bid request to openx url via GET, with mediaType specified as video', function () {
const request = spec.buildRequests([videoBidWithMediaType]);
expect(request[0].url).to.equal(`//${videoBidWithMediaType.params.delDomain}${URLBASEVIDEO}`);
expect(request[0].data.ph).to.be.undefined;
expect(request[0].method).to.equal('GET');
});
});
});
});
Expand Down

0 comments on commit 1b12943

Please sign in to comment.