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

Fixes unit tests in browsers other than chrome #1987

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 8 additions & 5 deletions modules/freewheelSSPBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ function getPricing(xmlNode) {
var princingData = {};

var extensions = xmlNode.querySelectorAll('Extension');
extensions.forEach(function(node) {
// Nodelist.forEach is not supported in IE and Edge
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces lint error on this line. The Atom eslint plugin is catching it, and it fails when built locally, but Travis build still isn't for some reason

// Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/
Array.prototype.forEach.call(extensions, function(node) {
if (node.getAttribute('type') === 'StickyPricing') {
pricingExtNode = node;
}
});
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for removing the semicolon?


if (pricingExtNode) {
var priceNode = pricingExtNode.querySelector('Price');
Expand All @@ -69,10 +71,11 @@ function getPricing(xmlNode) {
function getCreativeId(xmlNode) {
var creaId = '';
var adNodes = xmlNode.querySelectorAll('Ad');

adNodes.forEach(function(el) {
// Nodelist.forEach is not supported in IE and Edge
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces

// Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/
Array.prototype.forEach.call(adNodes, function(el) {
creaId += '[' + el.getAttribute('id') + ']';
});
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another semicolon removal to potentially add back in


return creaId;
}
Expand Down
6 changes: 3 additions & 3 deletions modules/rxrtbBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
isBidRequestValid: function (bidRequest) {
return 'params' in bidRequest && bidRequest.params.source !== undefined && bidRequest.params.id !== undefined && Number.isInteger(bidRequest.params.id) && bidRequest.params.token !== undefined;
return 'params' in bidRequest && bidRequest.params.source !== undefined && bidRequest.params.id !== undefined && utils.isInteger(bidRequest.params.id) && bidRequest.params.token !== undefined;
},
buildRequests: function (validBidRequests) {
var requests = [];
Expand Down Expand Up @@ -100,7 +100,7 @@ function makeImp(req) {
'banner': makeBanner(req)
};

if (req.params.bidfloor && Number.isInteger(req.params.bidfloor)) {
if (req.params.bidfloor && utils.isInteger(req.params.bidfloor)) {
imp.bidfloor = req.params.bidfloor
}

Expand All @@ -117,7 +117,7 @@ function makeBanner(req) {
});
}
banner.format = format;
if (req.params.pos && Number.isInteger(req.params.pos)) {
if (req.params.pos && utils.isInteger(req.params.pos)) {
banner.pos = req.params.pos;
}
return banner;
Expand Down
4 changes: 2 additions & 2 deletions modules/serverbidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ ServerBidServerAdapter = function ServerBidServerAdapter() {
}
}
if (data.placements.length) {
ajax(BASE_URI, _responseCallback(addBidResponse, bids), JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' });
ajax(BASE_URI, _responseCallback(addBidResponse, bids, done), JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' });
}
}
}

function _responseCallback(addBidResponse, bids) {
function _responseCallback(addBidResponse, bids, done) {
return function (resp) {
let bid;
let bidId;
Expand Down
13 changes: 13 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,16 @@ export function deletePropertyFromObject(object, prop) {
export function removeRequestId(bid) {
return exports.deletePropertyFromObject(bid, 'requestId');
}

/**
* Checks input is integer or not
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
* @param {*} value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces

*/
export function isInteger(value) {
if (Number.isInteger) {
return Number.isInteger(value);
} else {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
}