Skip to content

Commit

Permalink
siteId to string (#7818)
Browse files Browse the repository at this point in the history
Co-authored-by: Love Sharma <love.sharma@indexexchange.com>
  • Loading branch information
lksharma and Love Sharma authored Dec 14, 2021
1 parent a9fbb83 commit 07d1efc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
9 changes: 7 additions & 2 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function bidToImp(bid) {
imp.id = bid.bidId;

imp.ext = {};
imp.ext.siteID = bid.params.siteId;
imp.ext.siteID = bid.params.siteId.toString();

if (bid.params.hasOwnProperty('id') &&
(typeof bid.params.id === 'string' || typeof bid.params.id === 'number')) {
Expand Down Expand Up @@ -1188,7 +1188,12 @@ export const spec = {
}

if (typeof bid.params.siteId !== 'string' && typeof bid.params.siteId !== 'number') {
logError('IX Bid Adapter: siteId must be string or number value.', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
logError('IX Bid Adapter: siteId must be string or number type.', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
return false;
}

if (typeof bid.params.siteId !== 'string' && isNaN(Number(bid.params.siteId))) {
logError('IX Bid Adapter: siteId must valid value', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE });
return false;
}

Expand Down
24 changes: 18 additions & 6 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1560,11 +1560,23 @@ describe('IndexexchangeAdapter', function () {

expect(w).to.equal(size[0]);
expect(h).to.equal(size[1]);
expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId.toString());
expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
expect(ext.sid).to.equal(sidValue);
});
});

it('payload should have imp[].banner.format[].ext.siteID as string ', function () {
const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]);
bid.params.siteId = 1234;

request = spec.buildRequests([bid], DEFAULT_OPTION)[0];

const payload = JSON.parse(request.data.r);
payload.imp[0].banner.format.forEach((imp) => {
expect(imp.ext.siteID).to.be.a('string');
});
});

describe('build requests with price floors', () => {
const highFloor = 4.5;
const lowFloor = 3.5;
Expand Down Expand Up @@ -1696,7 +1708,7 @@ describe('IndexexchangeAdapter', function () {
expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]);
expect(impression.banner.format[0].h).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[1]);
expect(impression.banner.topframe).to.be.oneOf([0, 1]);
expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId.toString());
expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
expect(impression.banner.format[0].ext.sid).to.equal('50');
});

Expand All @@ -1710,7 +1722,7 @@ describe('IndexexchangeAdapter', function () {
expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]);
expect(impression.banner.format[0].h).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[1]);
expect(impression.banner.topframe).to.be.oneOf([0, 1]);
expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId.toString());
expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
expect(impression.banner.format[0].ext.sid).to.equal('abc');
});

Expand Down Expand Up @@ -1808,7 +1820,7 @@ describe('IndexexchangeAdapter', function () {

expect(w).to.equal(size[0]);
expect(h).to.equal(size[1]);
expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId.toString());
expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
expect(ext.sid).to.equal(sidValue);
});
});
Expand Down Expand Up @@ -1973,7 +1985,7 @@ describe('IndexexchangeAdapter', function () {

expect(w).to.equal(size[0]);
expect(h).to.equal(size[1]);
expect(ext.siteID).to.equal(bids[impressionIndex].params.siteId.toString());
expect(ext.siteID).to.equal(bids[impressionIndex].params.siteId);
expect(ext.sid).to.equal(sidValue);
});
});
Expand Down Expand Up @@ -2177,7 +2189,7 @@ describe('IndexexchangeAdapter', function () {

expect(w).to.equal(size[0]);
expect(h).to.equal(size[1]);
expect(ext.siteID).to.equal(bid.params.siteId.toString());
expect(ext.siteID).to.equal(bid.params.siteId);
expect(ext.sid).to.equal(sidValue);
});
});
Expand Down

0 comments on commit 07d1efc

Please sign in to comment.