-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1st version of the unit test for the raveltech bid adapter
- Loading branch information
1 parent
3faf9ea
commit ad754b8
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/raveltechBidAdapter.js'; | ||
|
||
const ENDPOINT = 'https://pb1.rvlproxy.net/bid/bid'; | ||
const RID_LENGTH = 10000; | ||
|
||
describe('RavelTechAdapter', function () { | ||
const bidRequests = [{ | ||
'bidder': 'raveltech', | ||
'params': { | ||
'placement_id': 234234 | ||
}, | ||
'userIdAsEids': [{ | ||
'source': 'not-eligible-source', | ||
'uids': [{ | ||
'id': '12345678' | ||
}] | ||
}, | ||
{ | ||
'source': 'adnxs.com', | ||
'uids': [{ | ||
'id': '5435546' | ||
}, | ||
{ | ||
'id': '2398645' | ||
}] | ||
}] | ||
}]; | ||
|
||
describe('inherited functions', function () { | ||
it('exists and is a function', function () { | ||
expect(adapter.callBids).to.exist.and.to.be.a('function'); | ||
}); | ||
}); | ||
|
||
describe('anonymizeBidRequests', function () { | ||
let anonymizedBidRequests; | ||
|
||
beforeEach(function() { | ||
anonymizedBidRequests = spec.buildRequests(bidRequests); | ||
if (!Array.isArray(anonymizedBidRequests)) { | ||
anonymizedBidRequests = [anonymizedBidRequests]; | ||
} | ||
}); | ||
|
||
it('should anonymize every id if the source is eligible for anonymization', function() { | ||
anonymizedBidRequests.forEach(bid => { | ||
bid.data = JSON.parse(bid.data); | ||
const eids = bid.data.eids; | ||
|
||
eids.forEach(eid => { | ||
if (eid.source === 'not-eligible-source') { return; } | ||
expect(typeof eid.id).to.equal('string'); | ||
expect(eid.id.length).to.be.at.least(RID_LENGTH); | ||
}) | ||
}) | ||
}); | ||
|
||
it('should empty the id if the source is not eligible for anonymization', function() { | ||
anonymizedBidRequests.forEach(bid => { | ||
bid.data = JSON.parse(bid.data); | ||
const eids = bid.data.eids; | ||
|
||
eids.forEach(eid => { | ||
if (eid.source !== 'not-eligible-source') { return; } | ||
expect(eid.id).to.satisfy(id => id === '' || (Array.isArray(id) && id.length === 0)); | ||
}) | ||
}) | ||
}); | ||
|
||
it('should update the URL of every bid request', function() { | ||
anonymizedBidRequests.forEach(bid => { | ||
expect(bid.url).to.equal(ENDPOINT); | ||
}); | ||
}); | ||
}); | ||
}); |