Skip to content

Commit

Permalink
Fixes unit tests in browsers other than chrome (prebid#1987)
Browse files Browse the repository at this point in the history
* Fixes unit tests in browsers other than chrome

* fixed lint errors
  • Loading branch information
jaiminpanchal27 authored and dluxemburg committed Jul 17, 2018
1 parent 37ce2e4 commit 97eb508
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
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;
}
}

0 comments on commit 97eb508

Please sign in to comment.