Skip to content

Commit

Permalink
Relaido Bid Adapter: support imuid (with utils fix after revert) (#7521)
Browse files Browse the repository at this point in the history
* Relaido Bid Adapter: support imuid 

`utils.` no longer needed because of specific import of functions

* update testing

* fix spaces

* fix test linting

* fix blank line padding
  • Loading branch information
ChrisHuie authored Sep 30, 2021
1 parent d7fc1a7 commit cd53743
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
10 changes: 8 additions & 2 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'relaido';
const BIDDER_DOMAIN = 'api.relaido.jp';
const ADAPTER_VERSION = '1.0.5';
const ADAPTER_VERSION = '1.0.6';
const DEFAULT_TTL = 300;
const UUID_KEY = 'relaido_uuid';

Expand Down Expand Up @@ -68,9 +68,15 @@ function buildRequests(validBidRequests, bidderRequest) {
media_type: mediaType,
uuid: uuid,
width: width,
height: height
height: height,
pv: '$prebid.version$'
};

const imuid = deepAccess(bidRequest, 'userId.imuid');
if (imuid) {
payload.imuid = imuid;
}

// It may not be encoded, so add it at the end of the payload
payload.ref = bidderRequest.refererInfo.referer;

Expand Down
41 changes: 21 additions & 20 deletions test/spec/modules/relaidoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ describe('RelaidoAdapter', function () {
let bidderRequest;
let serverResponse;
let serverRequest;
let generateUUIDStub;
let triggerPixelStub;

beforeEach(function () {
generateUUIDStub = sinon.stub(utils, 'generateUUID').returns(relaido_uuid);
triggerPixelStub = sinon.stub(utils, 'triggerPixel');
bidRequest = {
bidder: 'relaido',
params: {
Expand Down Expand Up @@ -73,6 +77,11 @@ describe('RelaidoAdapter', function () {
};
});

afterEach(() => {
generateUUIDStub.restore();
triggerPixelStub.restore();
});

describe('spec.isBidRequestValid', function () {
it('should return true when the required params are passed by video', function () {
expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
Expand Down Expand Up @@ -207,6 +216,7 @@ describe('RelaidoAdapter', function () {
expect(request.data.uuid).to.equal(relaido_uuid);
expect(request.data.width).to.equal(bidRequest.mediaTypes.video.playerSize[0][0]);
expect(request.data.height).to.equal(bidRequest.mediaTypes.video.playerSize[0][1]);
expect(request.data.pv).to.equal('$prebid.version$');
});

it('should build bid requests by banner', function () {
Expand Down Expand Up @@ -251,8 +261,6 @@ describe('RelaidoAdapter', function () {
expect(bidRequests).to.have.lengthOf(1);
const request = bidRequests[0];

// eslint-disable-next-line no-console
console.log(bidRequests);
expect(request.width).to.equal(1);
});

Expand All @@ -264,6 +272,15 @@ describe('RelaidoAdapter', function () {
expect(keys[0]).to.equal('version');
expect(keys[keys.length - 1]).to.equal('ref');
});

it('should get imuid', function () {
bidRequest.userId = {}
bidRequest.userId.imuid = 'i.tjHcK_7fTcqnbrS_YA2vaw';
const bidRequests = spec.buildRequests([bidRequest], bidderRequest);
expect(bidRequests).to.have.lengthOf(1);
const request = bidRequests[0];
expect(request.data.imuid).to.equal('i.tjHcK_7fTcqnbrS_YA2vaw');
});
});

describe('spec.interpretResponse', function () {
Expand Down Expand Up @@ -350,14 +367,6 @@ describe('RelaidoAdapter', function () {
});

describe('spec.onBidWon', function () {
let stub;
beforeEach(() => {
stub = sinon.stub(utils, 'triggerPixel');
});
afterEach(() => {
stub.restore();
});

it('Should create nurl pixel if bid nurl', function () {
let bid = {
bidder: bidRequest.bidder,
Expand All @@ -371,7 +380,7 @@ describe('RelaidoAdapter', function () {
ref: window.location.href,
}
spec.onBidWon(bid);
const parser = utils.parseUrl(stub.getCall(0).args[0]);
const parser = utils.parseUrl(triggerPixelStub.getCall(0).args[0]);
const query = parser.search;
expect(parser.hostname).to.equal('api.relaido.jp');
expect(parser.pathname).to.equal('/tr/v1/prebid/win.gif');
Expand All @@ -387,14 +396,6 @@ describe('RelaidoAdapter', function () {
});

describe('spec.onTimeout', function () {
let stub;
beforeEach(() => {
stub = sinon.stub(utils, 'triggerPixel');
});
afterEach(() => {
stub.restore();
});

it('Should create nurl pixel if bid nurl', function () {
const data = [{
bidder: bidRequest.bidder,
Expand All @@ -405,7 +406,7 @@ describe('RelaidoAdapter', function () {
timeout: bidderRequest.timeout,
}];
spec.onTimeout(data);
const parser = utils.parseUrl(stub.getCall(0).args[0]);
const parser = utils.parseUrl(triggerPixelStub.getCall(0).args[0]);
const query = parser.search;
expect(parser.hostname).to.equal('api.relaido.jp');
expect(parser.pathname).to.equal('/tr/v1/prebid/timeout.gif');
Expand Down

0 comments on commit cd53743

Please sign in to comment.