Skip to content

Commit

Permalink
tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadlob committed May 21, 2024
1 parent b160be2 commit 24ba29b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,23 @@ describe('Taboola Adapter', function () {
expect(res.data.user.id).to.deep.equal(bidderRequest.ortb2.user.id)
});

it('should pass user entities', function () {
const bidderRequest = {
...commonBidderRequest,
ortb2: {
user: {
id: 'userid',
buyeruid: 'buyeruid',
yob: 1990
}
}
}
const res = spec.buildRequests([defaultBidRequest], bidderRequest);
expect(res.data.user.id).to.deep.equal(bidderRequest.ortb2.user.id)
expect(res.data.user.buyeruid).to.deep.equal(bidderRequest.ortb2.user.buyeruid)
expect(res.data.user.yob).to.deep.equal(bidderRequest.ortb2.user.yob)
});

it('should pass pageType if exists in ortb2', function () {
const bidderRequest = {
...commonBidderRequest,
Expand Down Expand Up @@ -507,6 +524,28 @@ describe('Taboola Adapter', function () {
expect(res.data.user.buyeruid).to.equal('12121212');
});

it('should get buyeruid from cookie as priority and external user id from ortb2 object', function () {
getDataFromLocalStorage.returns(51525152);
hasLocalStorage.returns(false);
localStorageIsEnabled.returns(false);
cookiesAreEnabled.returns(true);
getCookie.returns('taboola%20global%3Auser-id=12121212');

const bidderRequest = {
...commonBidderRequest,
ortb2: {
user: {
id: 'userid',
buyeruid: 'buyeruid',
yob: 1990
}
}
};
const res = spec.buildRequests([defaultBidRequest], bidderRequest);
expect(res.data.user.id).to.deep.equal('userid')
expect(res.data.user.buyeruid).to.equal('12121212');
});

it('should get user id from cookie if local storage isn`t defined, only TGID_COOKIE_KEY exists', function () {
getDataFromLocalStorage.returns(51525152);
hasLocalStorage.returns(false);
Expand Down

0 comments on commit 24ba29b

Please sign in to comment.