Skip to content

Commit

Permalink
Update the checking rule of bid param for bridgewellBidAdapter (#5736)
Browse files Browse the repository at this point in the history
* Update the checking rule of bid param for bridgewellBidAdapter

* Update bridgewellBidAdapter.js

Co-authored-by: rigel_home <cycheng@bridgewell.com>
  • Loading branch information
rigelbibi and rigel_home authored Sep 14, 2020
1 parent 896cc0f commit 65b8dc0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/bridgewellBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import find from 'core-js-pure/features/array/find.js';

const BIDDER_CODE = 'bridgewell';
const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random();
const BIDDER_VERSION = '0.0.2';
const BIDDER_VERSION = '0.0.3';

export const spec = {
code: BIDDER_CODE,
Expand All @@ -19,11 +19,13 @@ export const spec = {
*/
isBidRequestValid: function (bid) {
let valid = false;

if (bid && bid.params && bid.params.ChannelID) {
valid = true;
if (bid && bid.params) {
if ((bid.params.cid) && (typeof bid.params.cid === 'number')) {
valid = true;
} else if (bid.params.ChannelID) {
valid = true;
}
}

return valid;
},

Expand Down
30 changes: 30 additions & 0 deletions test/spec/modules/bridgewellBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ describe('bridgewellBidAdapter', function () {
expect(spec.isBidRequestValid(validTag)).to.equal(true);
});

it('should return true when required params found', function () {
const validTag = {
'bidder': 'bridgewell',
'params': {
'cid': 1234
},
};
expect(spec.isBidRequestValid(validTag)).to.equal(true);
});

it('should return false when required params not found', function () {
const invalidTag = {
'bidder': 'bridgewell',
Expand All @@ -39,6 +49,26 @@ describe('bridgewellBidAdapter', function () {
};
expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
});

it('should return false when required params are empty', function () {
const invalidTag = {
'bidder': 'bridgewell',
'params': {
'cid': '',
},
};
expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
});

it('should return false when required param cid is not a number', function () {
const invalidTag = {
'bidder': 'bridgewell',
'params': {
'cid': 'bad_cid',
},
};
expect(spec.isBidRequestValid(invalidTag)).to.equal(false);
});
});

describe('buildRequests', function () {
Expand Down

0 comments on commit 65b8dc0

Please sign in to comment.