Skip to content

Commit

Permalink
SmartAdServer Bid Adapter: image sync and noAd (#6236)
Browse files Browse the repository at this point in the history
* SIM-889 Now we have image based sync

* SIM-889 Added test to check noad and image sync

* SIM-889 Fixing indenting issues
  • Loading branch information
lowendavid authored Feb 9, 2021
1 parent dde585b commit 73cfeb5
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
12 changes: 10 additions & 2 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const spec = {
const bidResponses = [];
let response = serverResponse.body;
try {
if (response) {
if (response && !response.isNoAd) {
const bidRequest = JSON.parse(bidRequestString.data);

let bidResponse = {
Expand All @@ -147,7 +147,8 @@ export const spec = {
dealId: response.dealId,
currency: response.currency,
netRevenue: response.isNetCpm,
ttl: response.ttl
ttl: response.ttl,
dspPixels: response.dspPixels
};

if (bidRequest.mediaType === VIDEO) {
Expand Down Expand Up @@ -182,6 +183,13 @@ export const spec = {
type: 'iframe',
url: serverResponses[0].body.cSyncUrl
});
} else if (syncOptions.pixelEnabled && serverResponses.length > 0 && serverResponses[0].body.dspPixels !== undefined) {
serverResponses[0].body.dspPixels.forEach(function(pixel) {
syncs.push({
type: 'image',
url: pixel
});
});
}
return syncs;
}
Expand Down
69 changes: 68 additions & 1 deletion test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,41 @@ describe('Smart bid adapter tests', function () {
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url'
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: false
}
};

var BID_RESPONSE_IS_NO_AD = {
body: {
cpm: 12,
width: 300,
height: 250,
creativeId: 'zioeufg',
currency: 'GBP',
isNetCpm: true,
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: true
}
};

var BID_RESPONSE_IMAGE_SYNC = {
body: {
cpm: 12,
width: 300,
height: 250,
creativeId: 'zioeufg',
currency: 'GBP',
isNetCpm: true,
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: false,
dspPixels: ['pixelOne', 'pixelTwo', 'pixelThree']
}
};

Expand Down Expand Up @@ -149,6 +183,18 @@ describe('Smart bid adapter tests', function () {
expect(requestContent).to.have.property('ckid').and.to.equal(42);
});

it('Verify parse response with no ad', function () {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE_IS_NO_AD, request[0]);
expect(bids).to.have.lengthOf(0);

expect(function () {
spec.interpretResponse(BID_RESPONSE_IS_NO_AD, {
data: 'invalid Json'
})
}).to.not.throw();
});

it('Verify parse response', function () {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE, request[0]);
Expand Down Expand Up @@ -258,6 +304,27 @@ describe('Smart bid adapter tests', function () {
expect(syncs).to.have.lengthOf(0);
});

it('Verifies user sync using dspPixels', function () {
var syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: true
}, [BID_RESPONSE_IMAGE_SYNC]);
expect(syncs).to.have.lengthOf(3);
expect(syncs[0].type).to.equal('image');

syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: false
}, [BID_RESPONSE_IMAGE_SYNC]);
expect(syncs).to.have.lengthOf(0);

syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: true
}, []);
expect(syncs).to.have.lengthOf(0);
});

describe('gdpr tests', function () {
afterEach(function () {
config.resetConfig();
Expand Down

0 comments on commit 73cfeb5

Please sign in to comment.