prebid.js 5.19.0 → 5.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +4 -5
- package/modules/adxcgBidAdapter.js +311 -359
- package/modules/airgridRtdProvider.js +1 -1
- package/modules/appnexusBidAdapter.js +9 -3
- package/modules/atsAnalyticsAdapter.js +67 -46
- package/modules/atsAnalyticsAdapter.md +1 -0
- package/modules/betweenBidAdapter.js +2 -1
- package/modules/browsiRtdProvider.js +106 -18
- package/modules/cleanioRtdProvider.js +192 -0
- package/modules/cleanioRtdProvider.md +59 -0
- package/modules/deltaprojectsBidAdapter.js +252 -0
- package/modules/deltaprojectsBidAdapter.md +32 -0
- package/modules/gridBidAdapter.js +1 -0
- package/modules/ipromBidAdapter.js +79 -0
- package/modules/ixBidAdapter.js +7 -1
- package/modules/jixieBidAdapter.js +8 -2
- package/modules/justpremiumBidAdapter.js +6 -1
- package/modules/kinessoIdSystem.js +1 -1
- package/modules/livewrappedAnalyticsAdapter.js +5 -0
- package/modules/multibid/index.js +3 -3
- package/modules/nativoBidAdapter.js +5 -1
- package/modules/openxBidAdapter.js +1 -1
- package/modules/operaadsBidAdapter.js +21 -1
- package/modules/otmBidAdapter.js +146 -0
- package/modules/otmBidAdapter.md +27 -26
- package/modules/outbrainBidAdapter.js +5 -0
- package/modules/playwireBidAdapter.md +61 -0
- package/modules/pubmaticBidAdapter.js +1 -1
- package/modules/rtdModule/index.js +2 -2
- package/modules/sonobiBidAdapter.js +7 -0
- package/modules/sortableBidAdapter.js +1 -0
- package/modules/teadsBidAdapter.js +3 -0
- package/modules/trustxBidAdapter.js +8 -6
- package/modules/ventesBidAdapter.js +370 -0
- package/modules/ventesBidAdapter.md +94 -0
- package/modules/yahoosspBidAdapter.js +6 -6
- package/package.json +1 -1
- package/src/auction.js +11 -11
- package/src/prebid.js +20 -4
- package/src/targeting.js +8 -0
- package/test/fixtures/fixtures.js +2 -1
- package/test/spec/modules/adxcgBidAdapter_spec.js +827 -571
- package/test/spec/modules/appnexusBidAdapter_spec.js +16 -1
- package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
- package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
- package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
- package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
- package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
- package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
- package/test/spec/modules/ixBidAdapter_spec.js +3 -3
- package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
- package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +23 -4
- package/test/spec/modules/multibid_spec.js +31 -31
- package/test/spec/modules/openxBidAdapter_spec.js +0 -26
- package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
- package/test/spec/modules/otmBidAdapter_spec.js +67 -0
- package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
- package/test/spec/modules/pubmaticBidAdapter_spec.js +40 -0
- package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
- package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
- package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
- package/test/spec/modules/trustxBidAdapter_spec.js +3 -3
- package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
- package/test/spec/unit/core/adapterManager_spec.js +7 -3
- package/test/spec/unit/core/targeting_spec.js +93 -0
- package/test/spec/unit/pbjs_api_spec.js +3 -1
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import {
|
|
3
|
+
BIDDER_CODE,
|
|
4
|
+
BIDDER_ENDPOINT_URL,
|
|
5
|
+
spec, USERSYNC_URL,
|
|
6
|
+
getBidFloor
|
|
7
|
+
} from 'modules/deltaprojectsBidAdapter.js';
|
|
8
|
+
|
|
9
|
+
const BID_REQ_REFER = 'http://example.com/page?param=val';
|
|
10
|
+
|
|
11
|
+
describe('deltaprojectsBidAdapter', function() {
|
|
12
|
+
describe('isBidRequestValid', function () {
|
|
13
|
+
function makeBid() {
|
|
14
|
+
return {
|
|
15
|
+
bidder: BIDDER_CODE,
|
|
16
|
+
params: {
|
|
17
|
+
publisherId: '12345'
|
|
18
|
+
},
|
|
19
|
+
adUnitCode: 'adunit-code',
|
|
20
|
+
sizes: [
|
|
21
|
+
[300, 250],
|
|
22
|
+
],
|
|
23
|
+
bidId: '30b31c1838de1e',
|
|
24
|
+
bidderRequestId: '22edbae2733bf6',
|
|
25
|
+
auctionId: '1d1a030790a475',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
it('should return true when bidder set correctly', function () {
|
|
30
|
+
expect(spec.isBidRequestValid(makeBid())).to.equal(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should return false when bid request is null', function () {
|
|
34
|
+
expect(spec.isBidRequestValid(undefined)).to.equal(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should return false when bidder not set correctly', function () {
|
|
38
|
+
let bid = makeBid();
|
|
39
|
+
delete bid.bidder;
|
|
40
|
+
expect(spec.isBidRequestValid(bid)).to.equal(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should return false when publisher id is not set', function () {
|
|
44
|
+
let bid = makeBid();
|
|
45
|
+
delete bid.params.publisherId;
|
|
46
|
+
expect(spec.isBidRequestValid(bid)).to.equal(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('buildRequests', function () {
|
|
51
|
+
const BIDREQ = {
|
|
52
|
+
bidder: BIDDER_CODE,
|
|
53
|
+
params: {
|
|
54
|
+
tagId: '403370',
|
|
55
|
+
siteId: 'example.com',
|
|
56
|
+
},
|
|
57
|
+
sizes: [
|
|
58
|
+
[300, 250],
|
|
59
|
+
],
|
|
60
|
+
bidId: '30b31c1838de1e',
|
|
61
|
+
bidderRequestId: '22edbae2733bf6',
|
|
62
|
+
auctionId: '1d1a030790a475',
|
|
63
|
+
}
|
|
64
|
+
const bidRequests = [BIDREQ];
|
|
65
|
+
const bannerRequest = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0];
|
|
66
|
+
const bannerRequestBody = bannerRequest.data;
|
|
67
|
+
|
|
68
|
+
it('send bid request with test tag if it is set in the param', function () {
|
|
69
|
+
const TEST_TAG = 1;
|
|
70
|
+
const bidRequest = Object.assign({}, BIDREQ, {
|
|
71
|
+
params: { ...BIDREQ.params, test: TEST_TAG },
|
|
72
|
+
});
|
|
73
|
+
const bidderRequest = { refererInfo: { referer: BID_REQ_REFER } };
|
|
74
|
+
const request = spec.buildRequests([bidRequest], bidderRequest)[0];
|
|
75
|
+
expect(request.data.test).to.equal(TEST_TAG);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('send bid request with correct timeout', function () {
|
|
79
|
+
const TMAX = 10;
|
|
80
|
+
const bidderRequest = { refererInfo: { referer: BID_REQ_REFER }, timeout: TMAX };
|
|
81
|
+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
|
|
82
|
+
expect(request.data.tmax).to.equal(TMAX);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('send bid request to the correct endpoint URL', function () {
|
|
86
|
+
expect(bannerRequest.url).to.equal(BIDDER_ENDPOINT_URL);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('sends bid request to our endpoint via POST', function () {
|
|
90
|
+
expect(bannerRequest.method).to.equal('POST');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('sends screen dimensions', function () {
|
|
94
|
+
expect(bannerRequestBody.device.w).to.equal(screen.width);
|
|
95
|
+
expect(bannerRequestBody.device.h).to.equal(screen.height);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('includes the ad size in the bid request', function () {
|
|
99
|
+
expect(bannerRequestBody.imp[0].banner.format[0].w).to.equal(BIDREQ.sizes[0][0]);
|
|
100
|
+
expect(bannerRequestBody.imp[0].banner.format[0].h).to.equal(BIDREQ.sizes[0][1]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('sets domain and href correctly', function () {
|
|
104
|
+
expect(bannerRequestBody.site.domain).to.equal(BIDREQ.params.siteId);
|
|
105
|
+
expect(bannerRequestBody.site.page).to.equal(BID_REQ_REFER);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const gdprBidRequests = [{
|
|
109
|
+
bidder: BIDDER_CODE,
|
|
110
|
+
params: {
|
|
111
|
+
tagId: '403370',
|
|
112
|
+
siteId: 'example.com'
|
|
113
|
+
},
|
|
114
|
+
sizes: [
|
|
115
|
+
[300, 250]
|
|
116
|
+
],
|
|
117
|
+
bidId: '30b31c1838de1e',
|
|
118
|
+
bidderRequestId: '22edbae2733bf6',
|
|
119
|
+
auctionId: '1d1a030790a475'
|
|
120
|
+
}];
|
|
121
|
+
const consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==';
|
|
122
|
+
|
|
123
|
+
const GDPR_REQ_REFERER = 'http://localhost:9876/'
|
|
124
|
+
function getGdprRequestBody(gdprApplies, consentString) {
|
|
125
|
+
const gdprRequest = spec.buildRequests(gdprBidRequests, {
|
|
126
|
+
gdprConsent: {
|
|
127
|
+
gdprApplies: gdprApplies,
|
|
128
|
+
consentString: consentString,
|
|
129
|
+
},
|
|
130
|
+
refererInfo: {
|
|
131
|
+
referer: GDPR_REQ_REFERER,
|
|
132
|
+
},
|
|
133
|
+
})[0];
|
|
134
|
+
return gdprRequest.data;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
it('should handle gdpr applies being present and true', function() {
|
|
138
|
+
const gdprRequestBody = getGdprRequestBody(true, consentString);
|
|
139
|
+
expect(gdprRequestBody.regs.ext.gdpr).to.equal(1);
|
|
140
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should handle gdpr applies being present and false', function() {
|
|
144
|
+
const gdprRequestBody = getGdprRequestBody(false, consentString);
|
|
145
|
+
expect(gdprRequestBody.regs.ext.gdpr).to.equal(0);
|
|
146
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should handle gdpr applies being undefined', function() {
|
|
150
|
+
const gdprRequestBody = getGdprRequestBody(undefined, consentString);
|
|
151
|
+
expect(gdprRequestBody.regs).to.deep.equal({ext: {}});
|
|
152
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should handle gdpr consent being undefined', function() {
|
|
156
|
+
const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: GDPR_REQ_REFERER }})[0];
|
|
157
|
+
const gdprRequestBody = gdprRequest.data;
|
|
158
|
+
expect(gdprRequestBody.regs).to.deep.equal({ ext: {} });
|
|
159
|
+
expect(gdprRequestBody.user).to.deep.equal({ ext: {} });
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('interpretResponse', function () {
|
|
164
|
+
const bidRequests = [
|
|
165
|
+
{
|
|
166
|
+
bidder: BIDDER_CODE,
|
|
167
|
+
params: {
|
|
168
|
+
tagId: '403370',
|
|
169
|
+
siteId: 'example.com',
|
|
170
|
+
currency: 'USD',
|
|
171
|
+
},
|
|
172
|
+
sizes: [
|
|
173
|
+
[300, 250],
|
|
174
|
+
],
|
|
175
|
+
bidId: '30b31c1838de1e',
|
|
176
|
+
bidderRequestId: '22edbae2733bf6',
|
|
177
|
+
auctionId: '1d1a030790a475',
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
const request = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0];
|
|
181
|
+
function makeResponse() {
|
|
182
|
+
return {
|
|
183
|
+
body: {
|
|
184
|
+
id: '5e5c23a5ba71e78',
|
|
185
|
+
seatbid: [
|
|
186
|
+
{
|
|
187
|
+
bid: [
|
|
188
|
+
{
|
|
189
|
+
id: '6vmb3isptf',
|
|
190
|
+
crid: 'deltaprojectscreative',
|
|
191
|
+
impid: '322add653672f68',
|
|
192
|
+
price: 1.22,
|
|
193
|
+
adm: '<!-- creative -->',
|
|
194
|
+
attr: [5],
|
|
195
|
+
h: 90,
|
|
196
|
+
nurl: 'http://nurl',
|
|
197
|
+
w: 728,
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
seat: 'MOCK'
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
bidid: '5e5c23a5ba71e78',
|
|
204
|
+
cur: 'USD'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const expectedBid = {
|
|
209
|
+
requestId: '322add653672f68',
|
|
210
|
+
cpm: 1.22,
|
|
211
|
+
width: 728,
|
|
212
|
+
height: 90,
|
|
213
|
+
creativeId: 'deltaprojectscreative',
|
|
214
|
+
dealId: null,
|
|
215
|
+
currency: 'USD',
|
|
216
|
+
netRevenue: true,
|
|
217
|
+
mediaType: 'banner',
|
|
218
|
+
ttl: 60,
|
|
219
|
+
ad: '<!-- creative --><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="http://nurl"></div>'
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
it('should get incorrect bid response if response body is missing', function () {
|
|
223
|
+
let response = makeResponse();
|
|
224
|
+
delete response.body;
|
|
225
|
+
let result = spec.interpretResponse(response, request);
|
|
226
|
+
expect(result.length).to.equal(0);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should get incorrect bid response if id or seat id of response body is missing', function () {
|
|
230
|
+
let response1 = makeResponse();
|
|
231
|
+
delete response1.body.id;
|
|
232
|
+
let result1 = spec.interpretResponse(response1, request);
|
|
233
|
+
expect(result1.length).to.equal(0);
|
|
234
|
+
|
|
235
|
+
let response2 = makeResponse();
|
|
236
|
+
delete response2.body.seatbid;
|
|
237
|
+
let result2 = spec.interpretResponse(response2, request);
|
|
238
|
+
expect(result2.length).to.equal(0);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should get the correct bid response', function () {
|
|
242
|
+
let result = spec.interpretResponse(makeResponse(), request);
|
|
243
|
+
expect(result.length).to.equal(1);
|
|
244
|
+
expect(result[0]).to.deep.equal(expectedBid);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should handle a missing crid', function () {
|
|
248
|
+
let noCridResponse = makeResponse();
|
|
249
|
+
delete noCridResponse.body.seatbid[0].bid[0].crid;
|
|
250
|
+
const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id;
|
|
251
|
+
let noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid});
|
|
252
|
+
let result = spec.interpretResponse(noCridResponse, request);
|
|
253
|
+
expect(result.length).to.equal(1);
|
|
254
|
+
expect(result[0]).to.deep.equal(noCridResult);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should handle a missing nurl', function () {
|
|
258
|
+
let noNurlResponse = makeResponse();
|
|
259
|
+
delete noNurlResponse.body.seatbid[0].bid[0].nurl;
|
|
260
|
+
let noNurlResult = Object.assign({}, expectedBid);
|
|
261
|
+
noNurlResult.ad = '<!-- creative -->';
|
|
262
|
+
let result = spec.interpretResponse(noNurlResponse, request);
|
|
263
|
+
expect(result.length).to.equal(1);
|
|
264
|
+
expect(result[0]).to.deep.equal(noNurlResult);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('handles empty bid response', function () {
|
|
268
|
+
let response = {
|
|
269
|
+
body: {
|
|
270
|
+
id: '5e5c23a5ba71e78',
|
|
271
|
+
seatbid: []
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
let result = spec.interpretResponse(response, request);
|
|
275
|
+
expect(result.length).to.equal(0);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should keep custom properties', () => {
|
|
279
|
+
const customProperties = {test: 'a test message', param: {testParam: 1}};
|
|
280
|
+
const expectedResult = Object.assign({}, expectedBid, {[spec.code]: customProperties});
|
|
281
|
+
const response = makeResponse();
|
|
282
|
+
response.body.seatbid[0].bid[0].ext = customProperties;
|
|
283
|
+
const result = spec.interpretResponse(response, request);
|
|
284
|
+
expect(result.length).to.equal(1);
|
|
285
|
+
expect(result[0]).to.deep.equal(expectedResult);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe('onBidWon', function () {
|
|
290
|
+
const OPEN_RTB_RESP = {
|
|
291
|
+
body: {
|
|
292
|
+
id: 'abc',
|
|
293
|
+
seatbid: [
|
|
294
|
+
{
|
|
295
|
+
bid: [
|
|
296
|
+
{
|
|
297
|
+
'id': 'abc*123*456',
|
|
298
|
+
'impid': 'xxxxxxx',
|
|
299
|
+
'price': 46.657196,
|
|
300
|
+
'adm': '<iframe id="dsp_iframe_228285197" src="https//abc/${AUCTION_PRICE:B64}&creative_id=123"></script>',
|
|
301
|
+
'adomain': ['deltaprojects.com'],
|
|
302
|
+
'h': 600,
|
|
303
|
+
'w': 300,
|
|
304
|
+
'cid': '868253',
|
|
305
|
+
'crid': '732935',
|
|
306
|
+
'cat': [],
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
'seat': '2147483647',
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
bidid: 'xyz',
|
|
313
|
+
cur: 'USD',
|
|
314
|
+
},
|
|
315
|
+
}
|
|
316
|
+
it('should replace auction price macro', () => {
|
|
317
|
+
const bid = spec.interpretResponse(OPEN_RTB_RESP)[0];
|
|
318
|
+
spec.onBidWon(bid);
|
|
319
|
+
expect(bid.ad).to.contains(`${Math.round(bid.cpm * 1000000)}`);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
describe('getUserSyncs', function () {
|
|
324
|
+
it('should not do user sync when pixel is disabled', () => {
|
|
325
|
+
const syncOptions = { pixelEnabled: false }
|
|
326
|
+
const result = spec.getUserSyncs(syncOptions)
|
|
327
|
+
expect(result.length).to.equal(0);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should do user sync without gdpr params when gdprConsent missing', () => {
|
|
331
|
+
const syncOptions = { pixelEnabled: true }
|
|
332
|
+
const gdprConsent = undefined
|
|
333
|
+
const result = spec.getUserSyncs(syncOptions, gdprConsent)
|
|
334
|
+
expect(result[0].url).to.equal(USERSYNC_URL);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should do user sync with gdpr params when gdprConsent exists', () => {
|
|
338
|
+
const syncOptions = { pixelEnabled: true }
|
|
339
|
+
const gdprConsent = {
|
|
340
|
+
gdprApplies: true,
|
|
341
|
+
consentString: 'ABCABCABC'
|
|
342
|
+
}
|
|
343
|
+
const expectedResult1 = USERSYNC_URL + `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`
|
|
344
|
+
const result1 = spec.getUserSyncs(syncOptions, {}, gdprConsent)
|
|
345
|
+
expect(result1[0].url).to.equal(expectedResult1);
|
|
346
|
+
|
|
347
|
+
delete gdprConsent.gdprApplies
|
|
348
|
+
const result2 = spec.getUserSyncs(syncOptions, {}, gdprConsent)
|
|
349
|
+
const expectedResult2 = USERSYNC_URL + `?gdpr_consent=${gdprConsent.consentString}`
|
|
350
|
+
expect(result2[0].url).to.equal(expectedResult2);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
describe('getBidFloor', () => {
|
|
355
|
+
it('should not get bid floor when getFloor is not defined', () => {
|
|
356
|
+
const bid = {};
|
|
357
|
+
const currency = 'SEK';
|
|
358
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
359
|
+
expect(result).to.be.undefined;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should not get bid floor when getFloor is not a function', () => {
|
|
363
|
+
const bid = { getFloor: 1.0 };
|
|
364
|
+
const currency = 'SEK';
|
|
365
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
366
|
+
expect(result).to.be.undefined;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should not get bid floor when getFloor return empty', () => {
|
|
370
|
+
const bid = { getFloor: () => ({}) };
|
|
371
|
+
const currency = 'SEK';
|
|
372
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
373
|
+
expect(result).to.be.undefined;
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('should not get bid floor in SEK when floor is not a number', () => {
|
|
377
|
+
const bid = { getFloor: () => ({ currency: 'SEK', floor: '1.0' }) };
|
|
378
|
+
const currency = 'SEK';
|
|
379
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
380
|
+
expect(result).to.be.undefined;
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('should get bid floor in USD when currency is not defined', () => {
|
|
384
|
+
const bid = { getFloor: () => ({ currency: 'USD', floor: 1.0 }) };
|
|
385
|
+
const currency = undefined;
|
|
386
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
387
|
+
expect(result.floor).to.equal(1.0);
|
|
388
|
+
expect(result.currency).to.equal('USD');
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('should get bid floor in SEK when currency is SEK', () => {
|
|
392
|
+
const bid = { getFloor: () => ({ currency: 'SEK', floor: 1.0 }) };
|
|
393
|
+
const currency = 'SEK';
|
|
394
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
395
|
+
expect(result.floor).to.equal(1.0);
|
|
396
|
+
expect(result.currency).to.equal('SEK');
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
@@ -328,26 +328,25 @@ describe('E-Planning Adapter', function () {
|
|
|
328
328
|
describe('buildRequests', function () {
|
|
329
329
|
let bidRequests = [validBid];
|
|
330
330
|
let sandbox;
|
|
331
|
+
let getWindowSelfStub;
|
|
332
|
+
let innerWidth;
|
|
331
333
|
beforeEach(() => {
|
|
332
334
|
sandbox = sinon.sandbox.create();
|
|
335
|
+
getWindowSelfStub = sandbox.stub(utils, 'getWindowSelf');
|
|
336
|
+
getWindowSelfStub.returns(createWindow(800));
|
|
333
337
|
});
|
|
334
338
|
|
|
335
339
|
afterEach(() => {
|
|
336
340
|
sandbox.restore();
|
|
337
341
|
});
|
|
338
342
|
|
|
339
|
-
const createWindow = () => {
|
|
343
|
+
const createWindow = (innerWidth) => {
|
|
340
344
|
const win = {};
|
|
341
345
|
win.self = win;
|
|
342
|
-
win.innerWidth =
|
|
346
|
+
win.innerWidth = innerWidth;
|
|
343
347
|
return win;
|
|
344
348
|
};
|
|
345
349
|
|
|
346
|
-
function setupSingleWindow(sandBox) {
|
|
347
|
-
const win = createWindow();
|
|
348
|
-
sandBox.stub(utils, 'getWindowSelf').returns(win);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
350
|
it('should create the url correctly', function () {
|
|
352
351
|
const url = spec.buildRequests(bidRequests, bidderRequest).url;
|
|
353
352
|
expect(url).to.equal('https://pbjs.e-planning.net/pbjs/1/' + CI + '/1/localhost/ROS');
|
|
@@ -516,7 +515,8 @@ describe('E-Planning Adapter', function () {
|
|
|
516
515
|
|
|
517
516
|
it('should return the e parameter with a value according to the sizes in order corresponding to the desktop priority list of the ad units', function () {
|
|
518
517
|
let bidRequestsPrioritySizes = [validBidExistingSizesInPriorityListForDesktop];
|
|
519
|
-
|
|
518
|
+
// overwrite default innerWdith for tests with a larger one we consider "Desktop" or NOT Mobile
|
|
519
|
+
getWindowSelfStub.returns(createWindow(1025));
|
|
520
520
|
const e = spec.buildRequests(bidRequestsPrioritySizes, bidderRequest).data.e;
|
|
521
521
|
expect(e).to.equal('300x250_0:300x250,300x600,970x250');
|
|
522
522
|
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {spec} from 'modules/ipromBidAdapter.js';
|
|
3
|
+
|
|
4
|
+
describe('iPROM Adapter', function () {
|
|
5
|
+
let bidRequests;
|
|
6
|
+
let bidderRequest;
|
|
7
|
+
|
|
8
|
+
beforeEach(function () {
|
|
9
|
+
bidRequests = [
|
|
10
|
+
{
|
|
11
|
+
bidder: 'iprom',
|
|
12
|
+
params: {
|
|
13
|
+
id: '1234',
|
|
14
|
+
dimension: '300x250',
|
|
15
|
+
},
|
|
16
|
+
adUnitCode: '/19966331/header-bid-tag-1',
|
|
17
|
+
mediaTypes: {
|
|
18
|
+
banner: {
|
|
19
|
+
sizes: [[300, 250], [300, 600]],
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
bidId: '29a72b151f7bd3',
|
|
23
|
+
auctionId: 'e36abb27-g3b1-1ad6-8a4c-701c8919d3hh',
|
|
24
|
+
bidderRequestId: '2z76da40m1b3cb8',
|
|
25
|
+
transactionId: 'j51lhf58-1ad6-g3b1-3j6s-912c9493g0gu'
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
bidderRequest = {
|
|
30
|
+
timeout: 3000,
|
|
31
|
+
refererInfo: {
|
|
32
|
+
referer: 'https://adserver.si/index.html',
|
|
33
|
+
reachedTop: true,
|
|
34
|
+
numIframes: 1,
|
|
35
|
+
stack: [
|
|
36
|
+
'https://adserver.si/index.html',
|
|
37
|
+
'https://adserver.si/iframe1.html',
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('validating bids', function () {
|
|
44
|
+
it('should accept valid bid', function () {
|
|
45
|
+
let validBid = {
|
|
46
|
+
bidder: 'iprom',
|
|
47
|
+
params: {
|
|
48
|
+
id: '1234',
|
|
49
|
+
dimension: '300x250',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const isValid = spec.isBidRequestValid(validBid);
|
|
54
|
+
|
|
55
|
+
expect(isValid).to.equal(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should reject bid if missing dimension and id', function () {
|
|
59
|
+
let invalidBid = {
|
|
60
|
+
bidder: 'iprom',
|
|
61
|
+
params: {}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
65
|
+
|
|
66
|
+
expect(isValid).to.equal(false);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should reject bid if missing dimension', function () {
|
|
70
|
+
let invalidBid = {
|
|
71
|
+
bidder: 'iprom',
|
|
72
|
+
params: {
|
|
73
|
+
id: '1234',
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
78
|
+
|
|
79
|
+
expect(isValid).to.equal(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should reject bid if dimension is not a string', function () {
|
|
83
|
+
let invalidBid = {
|
|
84
|
+
bidder: 'iprom',
|
|
85
|
+
params: {
|
|
86
|
+
id: '1234',
|
|
87
|
+
dimension: 404,
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
92
|
+
|
|
93
|
+
expect(isValid).to.equal(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should reject bid if missing id', function () {
|
|
97
|
+
let invalidBid = {
|
|
98
|
+
bidder: 'iprom',
|
|
99
|
+
params: {
|
|
100
|
+
dimension: '300x250',
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
105
|
+
|
|
106
|
+
expect(isValid).to.equal(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should reject bid if id is not a string', function () {
|
|
110
|
+
let invalidBid = {
|
|
111
|
+
bidder: 'iprom',
|
|
112
|
+
params: {
|
|
113
|
+
id: 1234,
|
|
114
|
+
dimension: '300x250',
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const isValid = spec.isBidRequestValid(invalidBid);
|
|
119
|
+
|
|
120
|
+
expect(isValid).to.equal(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('building requests', function () {
|
|
125
|
+
it('should go to correct endpoint', function () {
|
|
126
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
127
|
+
|
|
128
|
+
expect(request.method).to.exist;
|
|
129
|
+
expect(request.method).to.equal('POST');
|
|
130
|
+
expect(request.url).to.exist;
|
|
131
|
+
expect(request.url).to.equal('https://core.iprom.net/programmatic');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should add referer info', function () {
|
|
135
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
136
|
+
const requestparse = JSON.parse(request.data);
|
|
137
|
+
|
|
138
|
+
expect(requestparse.referer).to.exist;
|
|
139
|
+
expect(requestparse.referer.referer).to.equal('https://adserver.si/index.html');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should add adapter version', function () {
|
|
143
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
144
|
+
const requestparse = JSON.parse(request.data);
|
|
145
|
+
|
|
146
|
+
expect(requestparse.version).to.exist;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should contain id and dimension', function () {
|
|
150
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
151
|
+
const requestparse = JSON.parse(request.data);
|
|
152
|
+
|
|
153
|
+
expect(requestparse.bids[0].params.id).to.equal('1234');
|
|
154
|
+
expect(requestparse.bids[0].params.dimension).to.equal('300x250');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('handling responses', function () {
|
|
159
|
+
it('should return complete bid response', function () {
|
|
160
|
+
const serverResponse = {
|
|
161
|
+
body: [{
|
|
162
|
+
requestId: '29a72b151f7bd3',
|
|
163
|
+
cpm: 0.5,
|
|
164
|
+
width: '300',
|
|
165
|
+
height: '250',
|
|
166
|
+
creativeId: 1234,
|
|
167
|
+
ad: '<html><head><title>Iprom Header bidding example</title></head><body><img src="https://iprom.si/files/2015/08/iprom-logo.svg"></body></html>',
|
|
168
|
+
aDomains: ['https://example.com'],
|
|
169
|
+
}
|
|
170
|
+
]};
|
|
171
|
+
|
|
172
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
173
|
+
const bids = spec.interpretResponse(serverResponse, request);
|
|
174
|
+
|
|
175
|
+
expect(bids).to.be.lengthOf(1);
|
|
176
|
+
expect(bids[0].requestId).to.equal('29a72b151f7bd3');
|
|
177
|
+
expect(bids[0].cpm).to.equal(0.5);
|
|
178
|
+
expect(bids[0].width).to.equal('300');
|
|
179
|
+
expect(bids[0].height).to.equal('250');
|
|
180
|
+
expect(bids[0].ad).to.have.length.above(1);
|
|
181
|
+
expect(bids[0].meta.advertiserDomains).to.deep.equal(['https://example.com']);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should return empty bid response', function () {
|
|
185
|
+
const emptyServerResponse = {
|
|
186
|
+
body: []
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const request = spec.buildRequests(bidRequests, bidderRequest);
|
|
190
|
+
const bids = spec.interpretResponse(emptyServerResponse, request);
|
|
191
|
+
|
|
192
|
+
expect(bids).to.be.lengthOf(0);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -1405,16 +1405,16 @@ describe('IndexexchangeAdapter', function () {
|
|
|
1405
1405
|
}
|
|
1406
1406
|
};
|
|
1407
1407
|
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
|
|
1408
|
-
const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0]
|
|
1408
|
+
const { ext: { dfp_ad_unit_code } } = JSON.parse(requests[0].data.r).imp[0];
|
|
1409
1409
|
expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE);
|
|
1410
1410
|
});
|
|
1411
1411
|
|
|
1412
1412
|
it('should not send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot does not exists', function () {
|
|
1413
1413
|
const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
|
|
1414
1414
|
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
|
|
1415
|
-
const {
|
|
1415
|
+
const { ext } = JSON.parse(requests[0].data.r).imp[0];
|
|
1416
1416
|
|
|
1417
|
-
expect(
|
|
1417
|
+
expect(ext).to.not.exist;
|
|
1418
1418
|
});
|
|
1419
1419
|
|
|
1420
1420
|
it('payload should have correct format and value', function () {
|