Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validated size array and added tests #2870

Merged
merged 1 commit into from
Jul 20, 2018
Merged
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
20 changes: 6 additions & 14 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const tripleliftAdapterSpec = {

tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid');
tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$');
// tlCall = utils.tryAppendQueryString(tlCall, 'fe', _isFlashEnabled().toString());
tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer);

if (bidderRequest && bidderRequest.timeout) {
Expand Down Expand Up @@ -93,14 +92,19 @@ function _buildPostBody(bidRequests) {
}

function _sizes(sizeArray) {
return sizeArray.map(function(size) {
let sizes = sizeArray.filter(_isValidSize);
return sizes.map(function(size) {
return {
w: size[0],
h: size[1]
};
});
}

function _isValidSize(size) {
return (size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number');
}

function _buildResponseObject(bidderRequest, bid) {
let bidResponse = {};
let width = bid.width || 1;
Expand All @@ -125,16 +129,4 @@ function _buildResponseObject(bidderRequest, bid) {
return bidResponse;
}

// function _isFlashEnabled() {
// let flash;
// try {
// flash = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
// } catch (e) {
// flash = navigator.mimeTypes &&
// navigator.mimeTypes['application/x-shockwave-flash'] !== undefined &&
// navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin ? 1 : 0
// }
// return flash ? 1 : 0;
// }

registerBidder(tripleliftAdapterSpec);
8 changes: 7 additions & 1 deletion test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('triplelift adapter', () => {
floor: 1.0,
},
adUnitCode: 'adunit-code',
sizes: [[300, 250], [300, 600]],
sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
Expand All @@ -73,6 +73,12 @@ describe('triplelift adapter', () => {
expect(request).to.exist.and.to.be.a('object');
});

it('should only parse sizes that are of the proper length and format', () => {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
expect(request.data.imp[0].banner.format).to.have.length(2);
expect(request.data.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
});

it('should be a post request and populate the payload', () => {
const request = tripleliftAdapterSpec.buildRequests(bidRequests);
const payload = request.data;
Expand Down