Skip to content

Commit

Permalink
AdYouLike Bid Adapter: replace shorthand "image" native config (prebi…
Browse files Browse the repository at this point in the history
…d#6401)

* replace shrorthand "image" native type

* merge publisher native config with image type config

* add unit tests on native image config type
  • Loading branch information
guiann authored and seergiioo6 committed Mar 23, 2021
1 parent 7b189d7 commit 2ba0c96
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
32 changes: 31 additions & 1 deletion modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ const VERSION = '1.0';
const BIDDER_CODE = 'adyoulike';
const DEFAULT_DC = 'hb-api';

const NATIVE_IMAGE = {
image: {
required: true
},
title: {
required: true
},
sponsoredBy: {
required: true
},
clickUrl: {
required: true
},
body: {
required: false
},
icon: {
required: false
},
cta: {
required: false
}
};

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, NATIVE],
Expand Down Expand Up @@ -44,7 +68,13 @@ export const spec = {
accumulator[bid.bidId].Width = size.width;
accumulator[bid.bidId].Height = size.height;
accumulator[bid.bidId].AvailableSizes = sizesArray.join(',');
if (bid.mediaTypes && bid.mediaTypes.native) accumulator[bid.bidId].Native = bid.mediaTypes.native;
if (bid.mediaTypes && bid.mediaTypes.native) {
let nativeReq = bid.mediaTypes.native;
if (nativeReq.type === 'image') {
nativeReq = Object.assign({}, NATIVE_IMAGE, nativeReq);
}
accumulator[bid.bidId].Native = nativeReq;
}
return accumulator;
}, {}),
PageRefreshed: getPageRefreshed()
Expand Down
71 changes: 71 additions & 0 deletions test/spec/modules/adyoulikeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ describe('Adyoulike Adapter', function () {
}
];

const bidRequestWithNativeImageType = [
{
'bidId': 'bid_id_0',
'bidder': 'adyoulike',
'placementCode': 'adunit/hb-0',
'params': {
'placement': 'placement_0'
},
'sizes': '300x250',
'mediaTypes':
{
'native': {
'type': 'image',
'additional': {
'will': 'be',
'sent': ['300x250']
}
},
},
'transactionId': 'bid_id_0_transaction_id'
}
];

const sentBidNative = {
'bid_id_0': {
'PlacementID': 'e622af275681965d3095808561a1e510',
Expand Down Expand Up @@ -135,6 +158,37 @@ describe('Adyoulike Adapter', function () {
}
};

const sentNativeImageType = {
'additional': {
'sent': [
'300x250'
],
'will': 'be'
},
'body': {
'required': false
},
'clickUrl': {
'required': true
},
'cta': {
'required': false
},
'icon': {
'required': false
},
'image': {
'required': true
},
'sponsoredBy': {
'required': true
},
'title': {
'required': true
},
'type': 'image'
};

const bidRequestWithDCPlacement = [
{
'bidId': 'bid_id_0',
Expand Down Expand Up @@ -341,6 +395,23 @@ describe('Adyoulike Adapter', function () {
canonicalQuery.restore();
});

it('Should expand short native image config type', function() {
const request = spec.buildRequests(bidRequestWithNativeImageType, bidderRequest);
const payload = JSON.parse(request.data);

expect(request.url).to.contain(getEndpoint());
expect(request.method).to.equal('POST');
expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl));
expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl));
expect(request.url).to.contains('PublisherDomain=http%3A%2F%2Flocalhost%3A9876');

expect(payload.Version).to.equal('1.0');
expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0');
expect(payload.PageRefreshed).to.equal(false);
expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id');
expect(payload.Bids['bid_id_0'].Native).deep.equal(sentNativeImageType);
});

it('should add gdpr/usp consent information to the request', function () {
let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
let uspConsentData = '1YCC';
Expand Down

0 comments on commit 2ba0c96

Please sign in to comment.