Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

33Across Adapter: Removed the usage of utils library #1917

Merged
merged 5 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { registerBidder } = require('../src/adapters/bidderFactory');
const utils = require('../src/utils');

const BIDDER_CODE = '33across';
const END_POINT = 'https://ssc.33across.com/api/v1/hb';
Expand Down Expand Up @@ -116,12 +115,11 @@ function interpretResponse(serverResponse) {
}

// Register one sync per bid since each ad unit may potenitally be linked to a uniqe guid
function getUserSyncs(syncOptions) {
function getUserSyncs(syncOptions, bidderRequests) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second argument here is responses.
This calls adapter's getUserSync.

Since you need bidderRequests to do userSync. You can import userSync in your adapter and call userSync.registerSync from interpretResponse method.

Here is the hello_world test page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaiminpanchal27 Sorry, I am a confused. I was asked to introduce bidderRequests in getUserSyncs in #1855. Please see @mkendall07 comments. Did I misunderstand what was being asked?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@curlyblueeagle Sorry for this. You did exactly what was asked. We had some misunderstanding on the final outcome of the discussion.

Can you update with my suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Np, np. I'll update as you suggested and let you know. Thanks for the clarification

let syncs = [];
const ttxBidRequests = utils.getBidderRequestAllAdUnits(BIDDER_CODE).bids;

if (syncOptions.iframeEnabled) {
syncs = ttxBidRequests.map(_createSync);
syncs = bidderRequests.bids.map(_createSync);
}

return syncs;
Expand Down
108 changes: 50 additions & 58 deletions test/spec/modules/33acrossBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const { expect } = require('chai');
const utils = require('../../../src/utils');
const { isBidRequestValid, buildRequests, interpretResponse, getUserSyncs } = require('../../../modules/33acrossBidAdapter');
const {
isBidRequestValid,
buildRequests,
interpretResponse,
getUserSyncs
} = require('../../../modules/33acrossBidAdapter');

describe('33acrossBidAdapter:', function () {
const BIDDER_CODE = '33across';
Expand All @@ -21,8 +26,8 @@ describe('33acrossBidAdapter:', function () {
adUnitCode: 'div-id',
requestId: 'r1',
sizes: [
[300, 250],
[728, 90]
[ 300, 250 ],
[ 728, 90 ]
],
transactionId: 't1'
}
Expand Down Expand Up @@ -113,7 +118,7 @@ describe('33acrossBidAdapter:', function () {
describe('buildRequests:', function() {
it('returns corresponding server requests for each valid bidRequest', function() {
const ttxRequest = {
imp: [{
imp: [ {
banner: {
format: [
{
Expand All @@ -133,7 +138,7 @@ describe('33acrossBidAdapter:', function () {
prod: PRODUCT_ID
}
}
}],
} ],
site: {
id: SITE_ID
},
Expand Down Expand Up @@ -341,37 +346,41 @@ describe('33acrossBidAdapter:', function () {

describe('getUserSyncs', function() {
beforeEach(function() {
this.ttxBids = [
{
params: {
siteId: 'id1',
productId: 'p1'
}
},
{
params: {
siteId: 'id2',
productId: 'p1'
this.bidderRequests = {
bids: [
{
params: {
siteId: 'id1',
productId: 'p1'
}
},
{
params: {
siteId: 'id2',
productId: 'p1'
}
}
}
];
]
};

this.testTTXBids = [
{
params: {
site: { id: 'id1' },
productId: 'p1',
syncUrl: 'https://staging-de.tynt.com/deb/v2?m=xch'
}
},
{
params: {
site: { id: 'id2' },
productId: 'p1',
syncUrl: 'https://staging-de.tynt.com/deb/v2?m=xch'
this.testBidderRequests = {
bids: [
{
params: {
site: { id: 'id1' },
productId: 'p1',
syncUrl: 'https://staging-de.tynt.com/deb/v2?m=xch'
}
},
{
params: {
site: { id: 'id2' },
productId: 'p1',
syncUrl: 'https://staging-de.tynt.com/deb/v2?m=xch'
}
}
}
];
]
};

this.syncs = [
{
Expand All @@ -397,45 +406,28 @@ describe('33acrossBidAdapter:', function () {
});

context('when iframe is not enabled', function() {
it.skip('returns empty sync array', function() {
this.sandbox.stub(utils, 'getBidderRequestAllAdUnits', () => (
{
bids: this.ttxBids
}
));
it('returns empty sync array', function() {
const syncOptions = {};
expect(getUserSyncs(syncOptions)).to.deep.equal([]);
expect(getUserSyncs(syncOptions, this.bidderRequests)).to.deep.equal([]);
});
});

context('when iframe is enabled', function() {
it.skip('returns sync array equal to number of bids for ttx', function() {
this.sandbox.stub(utils, 'getBidderRequestAllAdUnits', () => (
{
bids: this.ttxBids
}
));

it('returns sync array equal to number of bids for ttx', function() {
const syncOptions = {
iframeEnabled: true
};
const syncs = getUserSyncs(syncOptions);
expect(syncs.length).to.equal(this.ttxBids.length);
const syncs = getUserSyncs(syncOptions, this.bidderRequests);
expect(syncs.length).to.equal(this.bidderRequests.bids.length);
expect(syncs).to.deep.equal(this.syncs);
});

it.skip('returns sync array equal to number of test bids for ttx', function() {
this.sandbox.stub(utils, 'getBidderRequestAllAdUnits', () => (
{
bids: this.testTTXBids
}
));

it('returns sync array equal to number of test bids for ttx', function() {
const syncOptions = {
iframeEnabled: true
};
const syncs = getUserSyncs(syncOptions);
expect(syncs.length).to.equal(this.testTTXBids.length);
const syncs = getUserSyncs(syncOptions, this.testBidderRequests);
expect(syncs.length).to.equal(this.testBidderRequests.bids.length);
expect(syncs).to.deep.equal(this.testSyncs);
});
});
Expand Down