prebid.js 5.18.0 → 5.20.2

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.
Files changed (114) hide show
  1. package/browsers.json +1 -0
  2. package/integrationExamples/gpt/akamaidap_segments_example.html +132 -0
  3. package/modules/.submodules.json +1 -0
  4. package/modules/adfBidAdapter.js +21 -16
  5. package/modules/adtelligentBidAdapter.js +2 -1
  6. package/modules/adxcgBidAdapter.js +311 -359
  7. package/modules/airgridRtdProvider.js +1 -1
  8. package/modules/akamaiDapRtdProvider.js +474 -0
  9. package/modules/akamaiDapRtdProvider.md +47 -0
  10. package/modules/appnexusBidAdapter.js +9 -3
  11. package/modules/atsAnalyticsAdapter.js +67 -46
  12. package/modules/atsAnalyticsAdapter.md +1 -0
  13. package/modules/betweenBidAdapter.js +20 -3
  14. package/modules/browsiRtdProvider.js +106 -18
  15. package/modules/cleanioRtdProvider.js +192 -0
  16. package/modules/cleanioRtdProvider.md +59 -0
  17. package/modules/codefuelBidAdapter.js +183 -0
  18. package/modules/codefuelBidAdapter.md +111 -0
  19. package/modules/connectIdSystem.js +104 -0
  20. package/modules/connectIdSystem.md +33 -0
  21. package/modules/deepintentBidAdapter.js +106 -9
  22. package/modules/deepintentBidAdapter.md +36 -1
  23. package/modules/deltaprojectsBidAdapter.js +252 -0
  24. package/modules/deltaprojectsBidAdapter.md +32 -0
  25. package/modules/engageyaBidAdapter.js +157 -0
  26. package/modules/gridBidAdapter.js +1 -0
  27. package/modules/gumgumBidAdapter.js +8 -0
  28. package/modules/inskinBidAdapter.js +7 -3
  29. package/modules/ipromBidAdapter.js +79 -0
  30. package/modules/ixBidAdapter.js +8 -1
  31. package/modules/jixieBidAdapter.js +8 -2
  32. package/modules/justpremiumBidAdapter.js +6 -1
  33. package/modules/kinessoIdSystem.js +1 -1
  34. package/modules/limelightDigitalBidAdapter.js +22 -2
  35. package/modules/livewrappedAnalyticsAdapter.js +49 -1
  36. package/modules/multibid/index.js +3 -3
  37. package/modules/nativoBidAdapter.js +5 -1
  38. package/modules/nextMillenniumBidAdapter.js +12 -3
  39. package/modules/oguryBidAdapter.js +14 -1
  40. package/modules/openxBidAdapter.js +34 -22
  41. package/modules/operaadsBidAdapter.js +21 -1
  42. package/modules/otmBidAdapter.js +146 -0
  43. package/modules/otmBidAdapter.md +27 -26
  44. package/modules/outbrainBidAdapter.js +5 -0
  45. package/modules/playwireBidAdapter.md +61 -0
  46. package/modules/publinkIdSystem.js +11 -6
  47. package/modules/rtdModule/index.js +2 -2
  48. package/modules/sonobiBidAdapter.js +7 -0
  49. package/modules/sortableBidAdapter.js +1 -0
  50. package/modules/teadsBidAdapter.js +3 -0
  51. package/modules/tripleliftBidAdapter.js +22 -5
  52. package/modules/trustxBidAdapter.js +8 -6
  53. package/modules/undertoneBidAdapter.js +9 -5
  54. package/modules/undertoneBidAdapter.md +5 -1
  55. package/modules/userId/eids.js +18 -0
  56. package/modules/userId/eids.md +7 -0
  57. package/modules/userId/userId.md +12 -0
  58. package/modules/ventesBidAdapter.js +370 -0
  59. package/modules/ventesBidAdapter.md +94 -0
  60. package/modules/videobyteBidAdapter.js +13 -6
  61. package/modules/videobyteBidAdapter.md +49 -0
  62. package/modules/yahoosspBidAdapter.js +6 -6
  63. package/modules/yieldmoSyntheticInventoryModule.js +46 -0
  64. package/modules/yieldmoSyntheticInventoryModule.md +68 -0
  65. package/package.json +1 -1
  66. package/src/adapterManager.js +5 -0
  67. package/src/adapters/bidderFactory.js +4 -3
  68. package/src/auction.js +11 -11
  69. package/src/constants.json +1 -0
  70. package/src/secureCreatives.js +6 -7
  71. package/src/targeting.js +11 -9
  72. package/test/spec/modules/adfBidAdapter_spec.js +83 -29
  73. package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
  74. package/test/spec/modules/adxcgBidAdapter_spec.js +827 -571
  75. package/test/spec/modules/akamaiDapRtdProvider_spec.js +246 -0
  76. package/test/spec/modules/appnexusBidAdapter_spec.js +16 -1
  77. package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
  78. package/test/spec/modules/betweenBidAdapter_spec.js +41 -0
  79. package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
  80. package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
  81. package/test/spec/modules/codefuelBidAdapter_spec.js +316 -0
  82. package/test/spec/modules/connectIdSystem_spec.js +189 -0
  83. package/test/spec/modules/deepintentBidAdapter_spec.js +153 -3
  84. package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
  85. package/test/spec/modules/engageyaBidAdapter_spec.js +286 -0
  86. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  87. package/test/spec/modules/gumgumBidAdapter_spec.js +5 -1
  88. package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
  89. package/test/spec/modules/ixBidAdapter_spec.js +13 -3
  90. package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
  91. package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
  92. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +155 -1
  93. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +52 -7
  94. package/test/spec/modules/multibid_spec.js +31 -31
  95. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +13 -1
  96. package/test/spec/modules/oguryBidAdapter_spec.js +53 -12
  97. package/test/spec/modules/openxBidAdapter_spec.js +85 -13
  98. package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
  99. package/test/spec/modules/otmBidAdapter_spec.js +67 -0
  100. package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
  101. package/test/spec/modules/publinkIdSystem_spec.js +6 -6
  102. package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
  103. package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
  104. package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
  105. package/test/spec/modules/tripleliftBidAdapter_spec.js +128 -0
  106. package/test/spec/modules/trustxBidAdapter_spec.js +3 -3
  107. package/test/spec/modules/undertoneBidAdapter_spec.js +52 -0
  108. package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
  109. package/test/spec/modules/videobyteBidAdapter_spec.js +2 -2
  110. package/test/spec/modules/yieldmoSyntheticInventoryModule_spec.js +89 -0
  111. package/test/spec/unit/core/adapterManager_spec.js +37 -2
  112. package/test/spec/unit/core/bidderFactory_spec.js +61 -1
  113. package/test/spec/unit/pbjs_api_spec.js +37 -2
  114. package/test/spec/unit/secureCreatives_spec.js +54 -25
@@ -0,0 +1,286 @@
1
+ import { expect } from 'chai';
2
+ import { spec } from 'modules/engageyaBidAdapter.js';
3
+ import * as utils from 'src/utils.js';
4
+
5
+ const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json';
6
+
7
+ export const _getUrlVars = function (url) {
8
+ var hash;
9
+ var myJson = {};
10
+ var hashes = url.slice(url.indexOf('?') + 1).split('&');
11
+ for (var i = 0; i < hashes.length; i++) {
12
+ hash = hashes[i].split('=');
13
+ myJson[hash[0]] = hash[1];
14
+ }
15
+ return myJson;
16
+ }
17
+
18
+ describe('engageya adapter', function () {
19
+ let bidRequests;
20
+ let nativeBidRequests;
21
+
22
+ beforeEach(function () {
23
+ bidRequests = [
24
+ {
25
+ bidder: 'engageya',
26
+ params: {
27
+ widgetId: 85610,
28
+ websiteId: 91140,
29
+ pageUrl: '[PAGE_URL]'
30
+ }
31
+ }
32
+ ]
33
+
34
+ nativeBidRequests = [
35
+ {
36
+ bidder: 'engageya',
37
+ params: {
38
+ widgetId: 85610,
39
+ websiteId: 91140,
40
+ pageUrl: '[PAGE_URL]'
41
+ },
42
+ nativeParams: {
43
+ title: {
44
+ required: true,
45
+ len: 80
46
+ },
47
+ image: {
48
+ required: true,
49
+ sizes: [150, 50]
50
+ },
51
+ sponsoredBy: {
52
+ required: true
53
+ }
54
+ }
55
+ }
56
+ ]
57
+ })
58
+ describe('isBidRequestValid', function () {
59
+ it('valid bid case', function () {
60
+ let validBid = {
61
+ bidder: 'engageya',
62
+ params: {
63
+ widgetId: 85610,
64
+ websiteId: 91140,
65
+ pageUrl: '[PAGE_URL]'
66
+ }
67
+ }
68
+ let isValid = spec.isBidRequestValid(validBid);
69
+ expect(isValid).to.equal(true);
70
+ });
71
+
72
+ it('invalid bid case: widgetId and websiteId is not passed', function () {
73
+ let validBid = {
74
+ bidder: 'engageya',
75
+ params: {}
76
+ }
77
+ let isValid = spec.isBidRequestValid(validBid);
78
+ expect(isValid).to.equal(false);
79
+ })
80
+
81
+ it('invalid bid case: widget id must be number', function () {
82
+ let invalidBid = {
83
+ bidder: 'engageya',
84
+ params: {
85
+ widgetId: '157746a',
86
+ websiteId: 91140,
87
+ pageUrl: '[PAGE_URL]'
88
+ }
89
+ }
90
+ let isValid = spec.isBidRequestValid(invalidBid);
91
+ expect(isValid).to.equal(false);
92
+ })
93
+ })
94
+
95
+ describe('buildRequests', function () {
96
+ it('sends bid request to ENDPOINT via GET', function () {
97
+ const request = spec.buildRequests(bidRequests)[0];
98
+ expect(request.url).to.include(ENDPOINT_URL);
99
+ expect(request.method).to.equal('GET');
100
+ });
101
+
102
+ it('buildRequests function should not modify original bidRequests object', function () {
103
+ let originalBidRequests = utils.deepClone(bidRequests);
104
+ let request = spec.buildRequests(bidRequests);
105
+ expect(bidRequests).to.deep.equal(originalBidRequests);
106
+ });
107
+
108
+ it('buildRequests function should not modify original nativeBidRequests object', function () {
109
+ let originalBidRequests = utils.deepClone(nativeBidRequests);
110
+ let request = spec.buildRequests(nativeBidRequests);
111
+ expect(nativeBidRequests).to.deep.equal(originalBidRequests);
112
+ });
113
+
114
+ it('Request params check', function () {
115
+ let request = spec.buildRequests(bidRequests)[0];
116
+ const data = _getUrlVars(request.url)
117
+ expect(parseInt(data.wid)).to.exist.and.to.equal(bidRequests[0].params.widgetId);
118
+ expect(parseInt(data.webid)).to.exist.and.to.equal(bidRequests[0].params.websiteId);
119
+ })
120
+ })
121
+
122
+ describe('interpretResponse', function () {
123
+ it('should return empty array if no response', function () {
124
+ const result = spec.interpretResponse({}, [])
125
+ expect(result).to.be.an('array').that.is.empty
126
+ });
127
+
128
+ it('should return empty array if no valid bids', function () {
129
+ let response = {
130
+ recs: [],
131
+ imageWidth: 300,
132
+ imageHeight: 250,
133
+ ireqId: '1d236f7890b',
134
+ pbtypeId: 2
135
+ };
136
+ let request = spec.buildRequests(bidRequests)[0];
137
+ const result = spec.interpretResponse({ body: response }, request)
138
+ expect(result).to.be.an('array').that.is.empty
139
+ });
140
+
141
+ it('should interpret native response', function () {
142
+ let serverResponse = {
143
+ recs: [
144
+ {
145
+ ecpm: 0.0920,
146
+ postId: '<!-- CREATIVE ID -->',
147
+ thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
148
+ domain: 'domain.test',
149
+ title: 'Test title',
150
+ clickUrl: '//click.test',
151
+ url: '//url.test',
152
+ displayName: 'Test displayName',
153
+ trackers: {
154
+ impressionPixels: ['//impression.test'],
155
+ viewPixels: ['//view.test'],
156
+ }
157
+ }
158
+ ],
159
+ imageWidth: 300,
160
+ imageHeight: 250,
161
+ ireqId: '1d236f7890b',
162
+ pbtypeId: 1
163
+ };
164
+ let expectedResult = [
165
+ {
166
+ requestId: '1d236f7890b',
167
+ cpm: 0.0920,
168
+ width: 300,
169
+ height: 250,
170
+ netRevenue: false,
171
+ currency: 'USD',
172
+ creativeId: '<!-- CREATIVE ID -->',
173
+ ttl: 360,
174
+ meta: {
175
+ advertiserDomains: ['domain.test']
176
+ },
177
+ native: {
178
+ title: 'Test title',
179
+ body: '',
180
+ image: {
181
+ url: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
182
+ width: 300,
183
+ height: 250
184
+ },
185
+ privacyLink: '',
186
+ clickUrl: '//click.test',
187
+ displayUrl: '//url.test',
188
+ cta: '',
189
+ sponsoredBy: 'Test displayName',
190
+ impressionTrackers: ['//impression.test', '//view.test'],
191
+ },
192
+ }
193
+ ];
194
+ let request = spec.buildRequests(bidRequests)[0];
195
+ let result = spec.interpretResponse({ body: serverResponse }, request);
196
+ expect(result).to.deep.equal(expectedResult);
197
+ });
198
+
199
+ it('should interpret display response', function () {
200
+ let serverResponse = {
201
+ recs: [
202
+ {
203
+ ecpm: 0.0920,
204
+ postId: '<!-- CREATIVE ID -->',
205
+ thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
206
+ domain: 'domain.test',
207
+ title: 'Test title',
208
+ clickUrl: '//click.test',
209
+ url: '//url.test',
210
+ displayName: 'Test displayName',
211
+ trackers: {
212
+ impressionPixels: ['//impression.test'],
213
+ viewPixels: ['//view.test'],
214
+ }
215
+ }
216
+ ],
217
+ imageWidth: 300,
218
+ imageHeight: 250,
219
+ ireqId: '1d236f7890b',
220
+ pbtypeId: 2,
221
+ widget: {
222
+ additionalData: '{"css":".eng_tag_ttl{display:block!important}"}'
223
+ }
224
+ };
225
+ let expectedResult = [
226
+ {
227
+ requestId: '1d236f7890b',
228
+ cpm: 0.0920,
229
+ width: 300,
230
+ height: 250,
231
+ netRevenue: false,
232
+ currency: 'USD',
233
+ creativeId: '<!-- CREATIVE ID -->',
234
+ ttl: 360,
235
+ meta: {
236
+ advertiserDomains: ['domain.test']
237
+ },
238
+ ad: `<html><body><style>.eng_tag_ttl{display:block!important}</style><div id="ENG_TAG"><a href="//click.test" target=_blank><img class="eng_tag_img" src="https://engageya.live/wp-content/uploads/2019/05/images.png" style="width:300px;height:250px;" alt="Test title"/><div class="eng_tag_brnd" style="display: none">Test displayName</div><div class="eng_tag_ttl" style="display: none">Test title</div></a><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="//impression.test"></div><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="//view.test"></div></div></body></html>`,
239
+ }
240
+ ];
241
+ let request = spec.buildRequests(bidRequests)[0];
242
+ let result = spec.interpretResponse({ body: serverResponse }, request);
243
+ expect(result).to.deep.equal(expectedResult);
244
+ });
245
+
246
+ it('should interpret display response without title', function () {
247
+ let serverResponse = {
248
+ recs: [
249
+ {
250
+ ecpm: 0.0920,
251
+ postId: '<!-- CREATIVE ID -->',
252
+ thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
253
+ domain: 'domain.test',
254
+ title: ' ',
255
+ clickUrl: '//click.test',
256
+ url: '//url.test',
257
+ displayName: 'Test displayName',
258
+ }
259
+ ],
260
+ imageWidth: 300,
261
+ imageHeight: 250,
262
+ ireqId: '1d236f7890b',
263
+ pbtypeId: 2,
264
+ };
265
+ let expectedResult = [
266
+ {
267
+ requestId: '1d236f7890b',
268
+ cpm: 0.0920,
269
+ width: 300,
270
+ height: 250,
271
+ netRevenue: false,
272
+ currency: 'USD',
273
+ creativeId: '<!-- CREATIVE ID -->',
274
+ ttl: 360,
275
+ meta: {
276
+ advertiserDomains: ['domain.test']
277
+ },
278
+ ad: `<html><body><div id="ENG_TAG"><a href="//click.test" target=_blank><img class="eng_tag_img" src="https://engageya.live/wp-content/uploads/2019/05/images.png" style="width:300px;height:250px;" alt=" "/></a></div></body></html>`,
279
+ }
280
+ ];
281
+ let request = spec.buildRequests(bidRequests)[0];
282
+ let result = spec.interpretResponse({ body: serverResponse }, request);
283
+ expect(result).to.deep.equal(expectedResult);
284
+ });
285
+ })
286
+ })
@@ -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 = 1025;
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
- setupSingleWindow(sandbox);
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
  });
@@ -531,9 +531,13 @@ describe('gumgumAdapter', function () {
531
531
  const jcsi = JSON.stringify(JCSI);
532
532
  const bidRequest = spec.buildRequests(bidRequests)[0];
533
533
  const actualKeys = Object.keys(JSON.parse(bidRequest.data.jcsi)).sort();
534
- expect(actualKeys).to.eq(actualKeys);
534
+ expect(actualKeys).to.eql(expectedKeys);
535
535
  expect(bidRequest.data.jcsi).to.eq(jcsi);
536
536
  });
537
+ it('should include the local time and timezone offset', function () {
538
+ const bidRequest = spec.buildRequests(bidRequests)[0];
539
+ expect(!!bidRequest.data.lt).to.be.true;
540
+ });
537
541
  })
538
542
 
539
543
  describe('interpretResponse', function () {
@@ -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
+ });
@@ -1377,6 +1377,11 @@ describe('IndexexchangeAdapter', function () {
1377
1377
  expect(requestUrl).to.equal(IX_SECURE_ENDPOINT);
1378
1378
  });
1379
1379
 
1380
+ it('auction type should be set correctly', function () {
1381
+ const at = JSON.parse(query.r).at;
1382
+ expect(at).to.equal(1);
1383
+ })
1384
+
1380
1385
  it('query object (version, siteID and request) should be correct', function () {
1381
1386
  expect(query.v).to.equal(BANNER_ENDPOINT_VERSION);
1382
1387
  expect(query.s).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId);
@@ -1400,16 +1405,16 @@ describe('IndexexchangeAdapter', function () {
1400
1405
  }
1401
1406
  };
1402
1407
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1403
- const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].banner.format[0].ext;
1408
+ const { ext: { dfp_ad_unit_code } } = JSON.parse(requests[0].data.r).imp[0];
1404
1409
  expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE);
1405
1410
  });
1406
1411
 
1407
1412
  it('should not send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot does not exists', function () {
1408
1413
  const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
1409
1414
  const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
1410
- const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].banner.format[0].ext;
1415
+ const { ext } = JSON.parse(requests[0].data.r).imp[0];
1411
1416
 
1412
- expect(dfp_ad_unit_code).to.not.exist;
1417
+ expect(ext).to.not.exist;
1413
1418
  });
1414
1419
 
1415
1420
  it('payload should have correct format and value', function () {
@@ -1929,6 +1934,11 @@ describe('IndexexchangeAdapter', function () {
1929
1934
  expect(query.nf).to.equal(1);
1930
1935
  });
1931
1936
 
1937
+ it('auction type should be set correctly', function () {
1938
+ const at = JSON.parse(query.r).at;
1939
+ expect(at).to.equal(1);
1940
+ })
1941
+
1932
1942
  it('impression should have correct format and value', function () {
1933
1943
  const impression = JSON.parse(query.r).imp[0];
1934
1944
  const sidValue = utils.parseGPTSingleSizeArray(DEFAULT_VIDEO_VALID_BID[0].params.size);