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 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
9 changes: 6 additions & 3 deletions modules/freewheelSSPBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function getPricing(xmlNode) {
var princingData = {};

var extensions = xmlNode.querySelectorAll('Extension');
extensions.forEach(function(node) {
// Nodelist.forEach is not supported in IE and Edge
// 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;
}
Expand All @@ -69,8 +71,9 @@ 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
// 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') + ']';
});

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
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
* @param {*} value
*/
export function isInteger(value) {
if (Number.isInteger) {
return Number.isInteger(value);
} else {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
}