Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
markkuhar committed Sep 12, 2023
1 parent 1d2e044 commit 4c653e4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/outbrainBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const NATIVE_PARAMS = {
const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';
const OB_USER_TOKEN_KEY = 'OB-USER-TOKEN';

const storage = getStorageManager({bidderCode: BIDDER_CODE});
export const storage = getStorageManager({bidderCode: BIDDER_CODE});

export const spec = {
code: BIDDER_CODE,
Expand Down
23 changes: 22 additions & 1 deletion test/spec/modules/outbrainBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { spec } from 'modules/outbrainBidAdapter.js';
import { spec, storage } from 'modules/outbrainBidAdapter.js';
import { config } from 'src/config.js';
import { server } from 'test/mocks/xhr';

Expand Down Expand Up @@ -213,6 +213,8 @@ describe('Outbrain Adapter', function () {
})

describe('buildRequests', function () {
let getDataFromLocalStorageStub;

before(() => {
config.setConfig({
outbrain: {
Expand Down Expand Up @@ -522,6 +524,25 @@ describe('Outbrain Adapter', function () {
]);
});

it('should pass OB user token', function () {
getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
getDataFromLocalStorageStub.returns('12345');

let bidRequest = {
bidId: 'bidId',
params: {},
...commonBidRequest,
};

let res = spec.buildRequests([bidRequest], commonBidderRequest);
const resData = JSON.parse(res.data)
expect(resData.user.ext.obusertoken).to.equal('12345')
expect(getDataFromLocalStorageStub.calledOnce).to.be.true;
sinon.assert.calledWith(getDataFromLocalStorageStub, 'OB-USER-TOKEN');

getDataFromLocalStorageStub.restore();
});

it('should pass bidfloor', function () {
const bidRequest = {
...commonBidRequest,
Expand Down

0 comments on commit 4c653e4

Please sign in to comment.