prebid.js 5.19.0 → 6.2.0

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 (161) hide show
  1. package/.babelrc.js +1 -10
  2. package/README.md +4 -2
  3. package/browsers.json +13 -37
  4. package/gulpfile.js +1 -0
  5. package/karma.conf.maker.js +1 -1
  6. package/modules/adheseBidAdapter.js +7 -2
  7. package/modules/adkernelBidAdapter.js +1 -0
  8. package/modules/adlivetechBidAdapter.md +61 -0
  9. package/modules/admixerBidAdapter.js +2 -1
  10. package/modules/adnuntiusBidAdapter.js +2 -1
  11. package/modules/adomikAnalyticsAdapter.js +10 -4
  12. package/modules/adplusBidAdapter.js +203 -0
  13. package/modules/adplusBidAdapter.md +39 -0
  14. package/modules/adyoulikeBidAdapter.js +7 -2
  15. package/modules/airgridRtdProvider.js +1 -1
  16. package/modules/appnexusBidAdapter.js +28 -5
  17. package/modules/atsAnalyticsAdapter.js +67 -46
  18. package/modules/atsAnalyticsAdapter.md +1 -0
  19. package/modules/beachfrontBidAdapter.js +14 -17
  20. package/modules/betweenBidAdapter.js +2 -1
  21. package/modules/browsiRtdProvider.js +106 -18
  22. package/modules/cleanioRtdProvider.js +192 -0
  23. package/modules/cleanioRtdProvider.md +59 -0
  24. package/modules/codefuelBidAdapter.js +1 -3
  25. package/modules/codefuelBidAdapter.md +3 -3
  26. package/modules/craftBidAdapter.js +5 -3
  27. package/modules/datablocksBidAdapter.js +3 -3
  28. package/modules/dchain.js +149 -0
  29. package/modules/dchain.md +45 -0
  30. package/modules/deepintentBidAdapter.js +1 -1
  31. package/modules/deltaprojectsBidAdapter.js +252 -0
  32. package/modules/deltaprojectsBidAdapter.md +32 -0
  33. package/modules/emx_digitalBidAdapter.js +9 -1
  34. package/modules/engageyaBidAdapter.js +68 -54
  35. package/modules/freewheel-sspBidAdapter.js +6 -0
  36. package/modules/glimpseBidAdapter.js +31 -16
  37. package/modules/goldbachBidAdapter.js +1176 -0
  38. package/modules/goldbachBidAdapter.md +151 -0
  39. package/modules/gptPreAuction.js +11 -5
  40. package/modules/gridBidAdapter.js +1 -0
  41. package/modules/gumgumBidAdapter.js +5 -1
  42. package/modules/id5IdSystem.md +6 -6
  43. package/modules/imRtdProvider.js +31 -0
  44. package/modules/intersectionRtdProvider.js +114 -0
  45. package/modules/invibesBidAdapter.js +15 -9
  46. package/modules/ipromBidAdapter.js +79 -0
  47. package/modules/ixBidAdapter.js +173 -22
  48. package/modules/jixieBidAdapter.js +8 -2
  49. package/modules/justpremiumBidAdapter.js +6 -1
  50. package/modules/limelightDigitalBidAdapter.js +2 -1
  51. package/modules/livewrappedAnalyticsAdapter.js +5 -0
  52. package/modules/luponmediaBidAdapter.js +570 -0
  53. package/modules/merkleIdSystem.js +5 -0
  54. package/modules/missenaBidAdapter.js +89 -0
  55. package/modules/multibid/index.js +3 -3
  56. package/modules/nativoBidAdapter.js +32 -2
  57. package/modules/oguryBidAdapter.js +2 -1
  58. package/modules/openxBidAdapter.js +7 -2
  59. package/modules/operaadsBidAdapter.js +21 -1
  60. package/modules/otmBidAdapter.js +146 -0
  61. package/modules/otmBidAdapter.md +27 -26
  62. package/modules/outbrainBidAdapter.js +5 -0
  63. package/modules/playwireBidAdapter.md +61 -0
  64. package/modules/prebidServerBidAdapter/index.js +3 -3
  65. package/modules/pubmaticBidAdapter.js +5 -3
  66. package/modules/relaidoBidAdapter.js +86 -65
  67. package/modules/richaudienceBidAdapter.js +1 -1
  68. package/modules/rtdModule/index.js +2 -2
  69. package/modules/saambaaBidAdapter.js +420 -0
  70. package/modules/saambaaBidAdapter.md +65 -68
  71. package/modules/seedtagBidAdapter.js +6 -0
  72. package/modules/smaatoBidAdapter.js +9 -1
  73. package/modules/smartxBidAdapter.js +17 -1
  74. package/modules/sonobiBidAdapter.js +7 -0
  75. package/modules/sortableBidAdapter.js +1 -0
  76. package/modules/sspBCBidAdapter.js +34 -3
  77. package/modules/tappxBidAdapter.js +3 -1
  78. package/modules/teadsBidAdapter.js +3 -0
  79. package/modules/trustxBidAdapter.js +18 -7
  80. package/modules/undertoneBidAdapter.js +8 -1
  81. package/modules/userId/index.js +27 -2
  82. package/modules/ventes.md +71 -0
  83. package/modules/ventesBidAdapter.js +410 -0
  84. package/modules/ventesBidAdapter.md +93 -0
  85. package/modules/vidoomyBidAdapter.js +51 -100
  86. package/modules/visxBidAdapter.js +20 -3
  87. package/modules/visxBidAdapter.md +4 -6
  88. package/modules/yahoosspBidAdapter.js +6 -6
  89. package/modules/yahoosspBidAdapter.md +1 -1
  90. package/modules/yieldlabBidAdapter.js +41 -10
  91. package/modules/yieldlabBidAdapter.md +91 -48
  92. package/modules/yieldoneBidAdapter.js +115 -11
  93. package/package.json +6 -1
  94. package/src/adapterManager.js +14 -8
  95. package/src/auction.js +14 -13
  96. package/src/targeting.js +2 -2
  97. package/src/utils.js +7 -0
  98. package/test/spec/integration/faker/googletag.js +6 -0
  99. package/test/spec/modules/adheseBidAdapter_spec.js +27 -1
  100. package/test/spec/modules/adnuntiusBidAdapter_spec.js +18 -0
  101. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  102. package/test/spec/modules/adplusBidAdapter_spec.js +213 -0
  103. package/test/spec/modules/adyoulikeBidAdapter_spec.js +26 -0
  104. package/test/spec/modules/appnexusBidAdapter_spec.js +65 -2
  105. package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
  106. package/test/spec/modules/beachfrontBidAdapter_spec.js +65 -1
  107. package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
  108. package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
  109. package/test/spec/modules/codefuelBidAdapter_spec.js +1 -1
  110. package/test/spec/modules/datablocksBidAdapter_spec.js +3 -3
  111. package/test/spec/modules/dchain_spec.js +329 -0
  112. package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
  113. package/test/spec/modules/emx_digitalBidAdapter_spec.js +10 -0
  114. package/test/spec/modules/engageyaBidAdapter_spec.js +231 -95
  115. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  116. package/test/spec/modules/freewheel-sspBidAdapter_spec.js +19 -0
  117. package/test/spec/modules/glimpseBidAdapter_spec.js +33 -0
  118. package/test/spec/modules/goldbachBidAdapter_spec.js +1359 -0
  119. package/test/spec/modules/gptPreAuction_spec.js +58 -4
  120. package/test/spec/modules/gumgumBidAdapter_spec.js +6 -0
  121. package/test/spec/modules/imRtdProvider_spec.js +25 -0
  122. package/test/spec/modules/intersectionRtdProvider_spec.js +141 -0
  123. package/test/spec/modules/invibesBidAdapter_spec.js +29 -4
  124. package/test/spec/modules/ipromBidAdapter_spec.js +195 -0
  125. package/test/spec/modules/ixBidAdapter_spec.js +288 -5
  126. package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
  127. package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
  128. package/test/spec/modules/konduitWrapper_spec.js +0 -1
  129. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +10 -7
  130. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +23 -4
  131. package/test/spec/modules/luponmediaBidAdapter_spec.js +412 -0
  132. package/test/spec/modules/merkleIdSystem_spec.js +18 -0
  133. package/test/spec/modules/missenaBidAdapter_spec.js +134 -0
  134. package/test/spec/modules/multibid_spec.js +31 -31
  135. package/test/spec/modules/nativoBidAdapter_spec.js +35 -18
  136. package/test/spec/modules/oguryBidAdapter_spec.js +13 -11
  137. package/test/spec/modules/openxBidAdapter_spec.js +5 -26
  138. package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
  139. package/test/spec/modules/otmBidAdapter_spec.js +67 -0
  140. package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
  141. package/test/spec/modules/prebidServerBidAdapter_spec.js +19 -2
  142. package/test/spec/modules/pubmaticBidAdapter_spec.js +1 -1
  143. package/test/spec/modules/relaidoBidAdapter_spec.js +71 -63
  144. package/test/spec/modules/seedtagBidAdapter_spec.js +3 -0
  145. package/test/spec/modules/smaatoBidAdapter_spec.js +61 -0
  146. package/test/spec/modules/smartxBidAdapter_spec.js +9 -0
  147. package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
  148. package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
  149. package/test/spec/modules/sspBCBidAdapter_spec.js +33 -3
  150. package/test/spec/modules/tappxBidAdapter_spec.js +4 -0
  151. package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
  152. package/test/spec/modules/trustxBidAdapter_spec.js +45 -3
  153. package/test/spec/modules/userId_spec.js +51 -0
  154. package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
  155. package/test/spec/modules/vidoomyBidAdapter_spec.js +32 -13
  156. package/test/spec/modules/visxBidAdapter_spec.js +121 -5
  157. package/test/spec/modules/yieldlabBidAdapter_spec.js +81 -0
  158. package/test/spec/modules/yieldoneBidAdapter_spec.js +299 -53
  159. package/test/spec/unit/core/adapterManager_spec.js +26 -7
  160. package/test/spec/unit/core/targeting_spec.js +44 -0
  161. package/wdio.conf.js +1 -1
@@ -197,15 +197,69 @@ describe('GPT pre-auction module', () => {
197
197
  code: 'slotCode3',
198
198
  }];
199
199
 
200
+ // first two adUnits directly pass in pbadslot => gpid is same
200
201
  const expectedAdUnits = [{
201
202
  code: 'adUnit1',
202
- ortb2Imp: { ext: { data: { pbadslot: '12345' } } }
203
- }, {
203
+ ortb2Imp: {
204
+ ext: {
205
+ data: {
206
+ pbadslot: '12345'
207
+ },
208
+ gpid: '12345'
209
+ }
210
+ }
211
+ },
212
+ // second adunit
213
+ {
204
214
  code: 'slotCode1',
205
- ortb2Imp: { ext: { data: { pbadslot: '67890', adserver: { name: 'gam', adslot: 'slotCode1' } } } }
215
+ ortb2Imp: {
216
+ ext: {
217
+ data: {
218
+ pbadslot: '67890',
219
+ adserver: {
220
+ name: 'gam',
221
+ adslot: 'slotCode1'
222
+ }
223
+ },
224
+ gpid: '67890'
225
+ }
226
+ }
206
227
  }, {
207
228
  code: 'slotCode3',
208
- ortb2Imp: { ext: { data: { pbadslot: 'slotCode3', adserver: { name: 'gam', adslot: 'slotCode3' } } } }
229
+ ortb2Imp: {
230
+ ext: {
231
+ data: {
232
+ pbadslot: 'slotCode3',
233
+ adserver: {
234
+ name: 'gam',
235
+ adslot: 'slotCode3'
236
+ }
237
+ },
238
+ gpid: 'slotCode3'
239
+ }
240
+ }
241
+ }];
242
+
243
+ window.googletag.pubads().setSlots(testSlots);
244
+ runMakeBidRequests(testAdUnits);
245
+ expect(returnedAdUnits).to.deep.equal(expectedAdUnits);
246
+ });
247
+
248
+ it('should not apply gpid if pbadslot was set by adUnitCode', () => {
249
+ const testAdUnits = [{
250
+ code: 'noMatchCode',
251
+ }];
252
+
253
+ // first two adUnits directly pass in pbadslot => gpid is same
254
+ const expectedAdUnits = [{
255
+ code: 'noMatchCode',
256
+ ortb2Imp: {
257
+ ext: {
258
+ data: {
259
+ pbadslot: 'noMatchCode'
260
+ },
261
+ }
262
+ }
209
263
  }];
210
264
 
211
265
  window.googletag.pubads().setSlots(testSlots);
@@ -152,6 +152,12 @@ describe('gumgumAdapter', function () {
152
152
  const zoneParam = { 'zone': '123a' };
153
153
  const pubIdParam = { 'pubId': 123 };
154
154
 
155
+ it('should set aun if the adUnitCode is available', function () {
156
+ const request = { ...bidRequests[0] };
157
+ const bidRequest = spec.buildRequests([request])[0];
158
+ expect(bidRequest.data.aun).to.equal(bidRequests[0].adUnitCode);
159
+ });
160
+
155
161
  it('should set pubId param if found', function () {
156
162
  const request = { ...bidRequests[0], params: pubIdParam };
157
163
  const bidRequest = spec.buildRequests([request])[0];
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  imRtdSubmodule,
3
3
  storage,
4
+ getBidderFunction,
4
5
  getCustomBidderFunction,
5
6
  setRealTimeData,
6
7
  getRealTimeData,
@@ -47,6 +48,30 @@ describe('imRtdProvider', function () {
47
48
  })
48
49
  })
49
50
 
51
+ describe('getBidderFunction', function () {
52
+ const assumedBidder = [
53
+ 'ix',
54
+ 'pubmatic'
55
+ ];
56
+ assumedBidder.forEach(bidderName => {
57
+ it(`should return bidderFunction with assumed bidder: ${bidderName}`, function () {
58
+ expect(getBidderFunction(bidderName)).to.exist.and.to.be.a('function');
59
+ });
60
+
61
+ it(`should return bid with correct key data: ${bidderName}`, function () {
62
+ const bid = {bidder: bidderName};
63
+ expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']})).to.equal(bid);
64
+ });
65
+ it(`should return bid without data: ${bidderName}`, function () {
66
+ const bid = {bidder: bidderName};
67
+ expect(getBidderFunction(bidderName)(bid, '')).to.equal(bid);
68
+ });
69
+ });
70
+ it(`should return null with unexpected bidder`, function () {
71
+ expect(getBidderFunction('test')).to.equal(null);
72
+ });
73
+ })
74
+
50
75
  describe('getCustomBidderFunction', function () {
51
76
  it('should return config function', function () {
52
77
  const config = {
@@ -0,0 +1,141 @@
1
+ import {config as _config, config} from 'src/config.js';
2
+ import { expect } from 'chai';
3
+ import events from 'src/events.js';
4
+ import * as prebidGlobal from 'src/prebidGlobal.js';
5
+ import { intersectionSubmodule } from 'modules/intersectionRtdProvider.js';
6
+ import * as utils from 'src/utils.js';
7
+ import {getGlobal} from 'src/prebidGlobal.js';
8
+ import 'src/prebid.js';
9
+
10
+ describe('Intersection RTD Provider', function () {
11
+ let sandbox;
12
+ let placeholder;
13
+ const pbjs = getGlobal();
14
+ const adUnit = {
15
+ code: 'ad-slot-1',
16
+ mediaTypes: {
17
+ banner: {
18
+ sizes: [ [300, 250] ]
19
+ }
20
+ },
21
+ bids: [
22
+ {
23
+ bidder: 'fake'
24
+ }
25
+ ]
26
+ };
27
+ const providerConfig = {name: 'intersection', waitForIt: true};
28
+ const rtdConfig = {realTimeData: {auctionDelay: 200, dataProviders: [providerConfig]}}
29
+ describe('IntersectionObserver not supported', function() {
30
+ beforeEach(function() {
31
+ sandbox = sinon.sandbox.create();
32
+ });
33
+ afterEach(function() {
34
+ sandbox.restore();
35
+ sandbox = undefined;
36
+ });
37
+ it('init should return false', function () {
38
+ sandbox.stub(window, 'IntersectionObserver').value(undefined);
39
+ expect(intersectionSubmodule.init({})).is.false;
40
+ });
41
+ });
42
+ describe('IntersectionObserver supported', function() {
43
+ beforeEach(function() {
44
+ sandbox = sinon.sandbox.create();
45
+ placeholder = createDiv();
46
+ append();
47
+ const __config = {};
48
+ sandbox.stub(_config, 'getConfig').callsFake(function (path) {
49
+ return utils.deepAccess(__config, path);
50
+ });
51
+ sandbox.stub(_config, 'setConfig').callsFake(function (obj) {
52
+ utils.mergeDeep(__config, obj);
53
+ });
54
+ });
55
+ afterEach(function() {
56
+ sandbox.restore();
57
+ remove();
58
+ sandbox = undefined;
59
+ placeholder = undefined;
60
+ pbjs.removeAdUnit();
61
+ });
62
+ it('init should return true', function () {
63
+ expect(intersectionSubmodule.init({})).is.true;
64
+ });
65
+ it('should set intersection. (request with "adUnitCodes")', function(done) {
66
+ pbjs.addAdUnits([utils.deepClone(adUnit)]);
67
+ config.setConfig(rtdConfig);
68
+ const onDone = sandbox.stub();
69
+ const requestBidObject = {adUnitCodes: [adUnit.code]};
70
+ intersectionSubmodule.init({});
71
+ intersectionSubmodule.getBidRequestData(
72
+ requestBidObject,
73
+ onDone,
74
+ providerConfig
75
+ );
76
+ setTimeout(function() {
77
+ expect(pbjs.adUnits[0].bids[0]).to.have.property('intersection');
78
+ done();
79
+ }, 200);
80
+ });
81
+ it('should set intersection. (request with "adUnits")', function(done) {
82
+ config.setConfig(rtdConfig);
83
+ const onDone = sandbox.stub();
84
+ const requestBidObject = {adUnits: [utils.deepClone(adUnit)]};
85
+ intersectionSubmodule.init();
86
+ intersectionSubmodule.getBidRequestData(
87
+ requestBidObject,
88
+ onDone,
89
+ providerConfig
90
+ );
91
+ setTimeout(function() {
92
+ expect(requestBidObject.adUnits[0].bids[0]).to.have.property('intersection');
93
+ done();
94
+ }, 200);
95
+ });
96
+ it('should set intersection. (request all)', function(done) {
97
+ pbjs.addAdUnits([utils.deepClone(adUnit)]);
98
+ config.setConfig(rtdConfig);
99
+ const onDone = sandbox.stub();
100
+ const requestBidObject = {};
101
+ intersectionSubmodule.init({});
102
+ intersectionSubmodule.getBidRequestData(
103
+ requestBidObject,
104
+ onDone,
105
+ providerConfig
106
+ );
107
+ setTimeout(function() {
108
+ expect(pbjs.adUnits[0].bids[0]).to.have.property('intersection');
109
+ done();
110
+ }, 200);
111
+ });
112
+ it('should call done due timeout', function(done) {
113
+ config.setConfig(rtdConfig);
114
+ remove();
115
+ const onDone = sandbox.stub();
116
+ const requestBidObject = {adUnits: [utils.deepClone(adUnit)]};
117
+ intersectionSubmodule.init({});
118
+ intersectionSubmodule.getBidRequestData(
119
+ requestBidObject,
120
+ onDone,
121
+ {...providerConfig, test: 1}
122
+ );
123
+ setTimeout(function() {
124
+ sinon.assert.calledOnce(onDone);
125
+ expect(requestBidObject.adUnits[0].bids[0]).to.not.have.property('intersection');
126
+ done();
127
+ }, 300);
128
+ });
129
+ });
130
+ function createDiv() {
131
+ const div = document.createElement('div');
132
+ div.id = adUnit.code;
133
+ return div;
134
+ }
135
+ function append() {
136
+ placeholder && document.body.appendChild(placeholder);
137
+ }
138
+ function remove() {
139
+ placeholder && placeholder.parentElement && placeholder.parentElement.removeChild(placeholder);
140
+ }
141
+ });
@@ -15,7 +15,7 @@ describe('invibesBidAdapter:', function () {
15
15
  params: {
16
16
  placementId: PLACEMENT_ID
17
17
  },
18
- adUnitCode: 'test-div',
18
+ adUnitCode: 'test-div1',
19
19
  auctionId: 'a1',
20
20
  sizes: [
21
21
  [300, 250],
@@ -30,7 +30,7 @@ describe('invibesBidAdapter:', function () {
30
30
  params: {
31
31
  placementId: 'abcde'
32
32
  },
33
- adUnitCode: 'test-div',
33
+ adUnitCode: 'test-div2',
34
34
  auctionId: 'a2',
35
35
  sizes: [
36
36
  [300, 250],
@@ -48,7 +48,7 @@ describe('invibesBidAdapter:', function () {
48
48
  params: {
49
49
  placementId: PLACEMENT_ID
50
50
  },
51
- adUnitCode: 'test-div',
51
+ adUnitCode: 'test-div1',
52
52
  auctionId: 'a1',
53
53
  sizes: [
54
54
  [300, 250],
@@ -67,7 +67,7 @@ describe('invibesBidAdapter:', function () {
67
67
  params: {
68
68
  placementId: 'abcde'
69
69
  },
70
- adUnitCode: 'test-div',
70
+ adUnitCode: 'test-div2',
71
71
  auctionId: 'a2',
72
72
  sizes: [
73
73
  [300, 250],
@@ -223,6 +223,12 @@ describe('invibesBidAdapter:', function () {
223
223
  expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[1].params.placementId);
224
224
  });
225
225
 
226
+ it('sends all adUnitCodes', function () {
227
+ const request = spec.buildRequests(bidRequests);
228
+ expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[0].adUnitCode);
229
+ expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[1].adUnitCode);
230
+ });
231
+
226
232
  it('sends all Placement Ids and userId', function () {
227
233
  const request = spec.buildRequests(bidRequestsWithUserId);
228
234
  expect(JSON.parse(request.data.bidParamsJson).userId).to.exist;
@@ -823,6 +829,20 @@ describe('invibesBidAdapter:', function () {
823
829
  }
824
830
  };
825
831
 
832
+ let responseWithAdUnit = {
833
+ Ads: [{
834
+ BidPrice: 0.5,
835
+ VideoExposedId: 123
836
+ }],
837
+ BidModel: {
838
+ BidVersion: 1,
839
+ PlacementId: '12345_test-div1',
840
+ AuctionStartTime: Date.now(),
841
+ CreativeHtml: '<!-- Creative -->'
842
+ },
843
+ UseAdUnitCode: true
844
+ };
845
+
826
846
  var buildResponse = function(placementId, cid, blcids, creativeId) {
827
847
  return {
828
848
  MultipositionEnabled: true,
@@ -911,6 +931,11 @@ describe('invibesBidAdapter:', function () {
911
931
  let secondResult = spec.interpretResponse({body: response}, {bidRequests});
912
932
  expect(secondResult).to.be.empty;
913
933
  });
934
+
935
+ it('bids using the adUnitCode', function () {
936
+ let result = spec.interpretResponse({body: responseWithAdUnit}, {bidRequests});
937
+ expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0]));
938
+ });
914
939
  });
915
940
 
916
941
  context('when the response has meta', 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
+ });