Skip to content

Commit

Permalink
final fixes after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Nasti committed May 24, 2022
1 parent c69351c commit 80d7fca
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 77 deletions.
3 changes: 0 additions & 3 deletions modules/engageyaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { createTrackPixelHtml } from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const {
registerBidder
} = require('../src/adapters/bidderFactory.js');
const BIDDER_CODE = 'engageya';
const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json';
const ENDPOINT_METHOD = 'GET';
Expand Down
149 changes: 75 additions & 74 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,90 +1347,91 @@ describe('S2S Adapter', function () {
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.imp[0].native).to.deep.equal({
request: JSON.stringify({
'context': 1,
'plcmttype': 1,
'eventtrackers': [{
event: 1,
methods: [1]
}],
'assets': [
{
'required': 1,
'id': 0,
'title': {
'len': 800
}
},
{
'required': 1,
'id': 1,
'img': {
'type': 3,
'w': 989,
'h': 742
}
},
{
'required': 1,
'id': 2,
'img': {
'type': 1,
'wmin': 10,
'hmin': 10,
'ext': {
'aspectratios': ['1:1']
expect(requestBid.imp[0].native).to.deep.equal({
request: JSON.stringify({
'context': 1,
'plcmttype': 1,
'eventtrackers': [{
event: 1,
methods: [1]
}],
'assets': [
{
'required': 1,
'id': 0,
'title': {
'len': 800
}
},
{
'required': 1,
'id': 1,
'img': {
'type': 3,
'w': 989,
'h': 742
}
},
{
'required': 1,
'id': 2,
'img': {
'type': 1,
'wmin': 10,
'hmin': 10,
'ext': {
'aspectratios': ['1:1']
}
}
},
{
'required': 1,
'id': 3,
'data': {
'type': 1
}
}
},
{
'required': 1,
'id': 3,
'data': {
'type': 1
}
}
]
}),
ver: '1.2'
]
}),
ver: '1.2'
});
});
});

it('adds native ortb request for OpenRTB', function () {
const _config = {
s2sConfig: CONFIG
};
it('adds native ortb request for OpenRTB', function () {
const _config = {
s2sConfig: CONFIG
};

const openRtbNativeRequest = deepClone(REQUEST);
delete openRtbNativeRequest.ad_units[0].mediaTypes.native;
delete openRtbNativeRequest.ad_units[0].nativeParams;
const openRtbNativeRequest = deepClone(REQUEST);
delete openRtbNativeRequest.ad_units[0].mediaTypes.native;
delete openRtbNativeRequest.ad_units[0].nativeParams;

openRtbNativeRequest.ad_units[0].mediaTypes.native = NATIVE_ORTB_MTO;
prepRequest(openRtbNativeRequest);
openRtbNativeRequest.ad_units[0].mediaTypes.native = NATIVE_ORTB_MTO;
prepRequest(openRtbNativeRequest);

config.setConfig(_config);
adapter.callBids(openRtbNativeRequest, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
config.setConfig(_config);
adapter.callBids(openRtbNativeRequest, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.imp[0].native).to.deep.equal({
request: JSON.stringify(NATIVE_ORTB_MTO.ortb),
ver: '1.2'
expect(requestBid.imp[0].native).to.deep.equal({
request: JSON.stringify(NATIVE_ORTB_MTO.ortb),
ver: '1.2'
});
});
});

it('should not include ext.aspectratios if adunit\'s aspect_ratios do not define radio_width and ratio_height', () => {
const req = deepClone(REQUEST);
req.ad_units[0].mediaTypes.native.icon.aspect_ratios[0] = { 'min_width': 1, 'min_height': 2 };
prepRequest(req);
adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax);
const nativeReq = JSON.parse(JSON.parse(server.requests[0].requestBody).imp[0].native.request);
const icons = nativeReq.assets.map((a) => a.img).filter((img) => img && img.type === 1);
expect(icons).to.have.length(1);
expect(icons[0].hmin).to.equal(2);
expect(icons[0].wmin).to.equal(1);
expect(deepAccess(icons[0], 'ext.aspectratios')).to.be.undefined;
})
it('should not include ext.aspectratios if adunit\'s aspect_ratios do not define radio_width and ratio_height', () => {
const req = deepClone(REQUEST);
req.ad_units[0].mediaTypes.native.icon.aspect_ratios[0] = { 'min_width': 1, 'min_height': 2 };
prepRequest(req);
adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax);
const nativeReq = JSON.parse(JSON.parse(server.requests[0].requestBody).imp[0].native.request);
const icons = nativeReq.assets.map((a) => a.img).filter((img) => img && img.type === 1);
expect(icons).to.have.length(1);
expect(icons[0].hmin).to.equal(2);
expect(icons[0].wmin).to.equal(1);
expect(deepAccess(icons[0], 'ext.aspectratios')).to.be.undefined;
})
});

it('adds site if app is not present', function () {
const _config = {
Expand Down

0 comments on commit 80d7fca

Please sign in to comment.