prebid.js 6.5.0 → 6.9.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 (139) hide show
  1. package/.eslintrc.js +8 -1
  2. package/integrationExamples/gpt/amp/creative.html +11 -33
  3. package/integrationExamples/gpt/weboramaRtdProvider_example.html +154 -115
  4. package/integrationExamples/gpt/x-domain/creative.html +63 -29
  5. package/modules/.submodules.json +2 -1
  6. package/modules/adagioBidAdapter.js +0 -8
  7. package/modules/adagioBidAdapter.md +1 -1
  8. package/modules/adbookpspBidAdapter.js +27 -10
  9. package/modules/adhashBidAdapter.js +3 -3
  10. package/modules/adkernelBidAdapter.js +2 -1
  11. package/modules/admanBidAdapter.js +10 -4
  12. package/modules/adomikAnalyticsAdapter.js +23 -11
  13. package/modules/adqueryIdSystem.js +103 -0
  14. package/modules/adqueryIdSystem.md +35 -0
  15. package/modules/appnexusBidAdapter.js +14 -2
  16. package/modules/asealBidAdapter.js +58 -0
  17. package/modules/asealBidAdapter.md +52 -0
  18. package/modules/bliinkBidAdapter.js +2 -1
  19. package/modules/brandmetricsRtdProvider.js +168 -0
  20. package/modules/brandmetricsRtdProvider.md +40 -0
  21. package/modules/colossussspBidAdapter.js +12 -8
  22. package/modules/colossussspBidAdapter.md +15 -1
  23. package/modules/compassBidAdapter.js +10 -3
  24. package/modules/consumableBidAdapter.md +1 -1
  25. package/modules/conversantBidAdapter.js +7 -0
  26. package/modules/criteoBidAdapter.js +10 -1
  27. package/modules/criteoIdSystem.js +29 -7
  28. package/modules/currency.js +26 -1
  29. package/modules/displayioBidAdapter.js +157 -0
  30. package/modules/displayioBidAdapter.md +148 -0
  31. package/modules/e_volutionBidAdapter.js +158 -0
  32. package/modules/glimpseBidAdapter.js +66 -44
  33. package/modules/gnetBidAdapter.js +3 -3
  34. package/modules/gnetBidAdapter.md +4 -4
  35. package/modules/gumgumBidAdapter.js +56 -42
  36. package/modules/idImportLibrary.js +45 -8
  37. package/modules/idImportLibrary.md +4 -0
  38. package/modules/improvedigitalBidAdapter.js +29 -2
  39. package/modules/interactiveOffersBidAdapter.js +9 -6
  40. package/modules/jwplayerRtdProvider.js +71 -6
  41. package/modules/jwplayerRtdProvider.md +27 -11
  42. package/modules/kargoBidAdapter.js +2 -2
  43. package/modules/lunamediahbBidAdapter.js +32 -4
  44. package/modules/nextMillenniumBidAdapter.js +3 -1
  45. package/modules/oguryBidAdapter.js +14 -14
  46. package/modules/onetagBidAdapter.js +4 -2
  47. package/modules/pilotxBidAdapter.js +147 -0
  48. package/modules/pilotxBidAdapter.md +50 -0
  49. package/modules/priceFloors.js +2 -1
  50. package/modules/proxistoreBidAdapter.js +0 -2
  51. package/modules/pubmaticAnalyticsAdapter.js +16 -0
  52. package/modules/richaudienceBidAdapter.js +10 -4
  53. package/modules/riseBidAdapter.js +18 -7
  54. package/modules/rtbhouseBidAdapter.js +14 -4
  55. package/modules/rtdModule/index.js +14 -15
  56. package/modules/rubiconAnalyticsAdapter.js +8 -2
  57. package/modules/seedingAllianceBidAdapter.js +3 -3
  58. package/modules/sharethroughBidAdapter.js +12 -17
  59. package/modules/showheroes-bsBidAdapter.js +13 -2
  60. package/modules/sortableAnalyticsAdapter.js +5 -4
  61. package/modules/sovrnBidAdapter.js +93 -18
  62. package/modules/sovrnBidAdapter.md +80 -2
  63. package/modules/synacormediaBidAdapter.js +31 -10
  64. package/modules/tappxBidAdapter.js +8 -5
  65. package/modules/teadsBidAdapter.js +1 -2
  66. package/modules/undertoneBidAdapter.js +17 -1
  67. package/modules/userId/eids.js +7 -1
  68. package/modules/userId/userId.md +8 -0
  69. package/modules/viewability.js +177 -0
  70. package/modules/viewability.md +87 -0
  71. package/modules/weboramaRtdProvider.js +264 -34
  72. package/modules/weboramaRtdProvider.md +110 -40
  73. package/modules/welectBidAdapter.js +106 -0
  74. package/modules/yahoosspBidAdapter.js +2 -0
  75. package/package.json +2 -1
  76. package/src/adRendering.js +38 -0
  77. package/src/adloader.js +2 -1
  78. package/src/auction.js +103 -73
  79. package/src/bidderSettings.js +69 -0
  80. package/src/hook.js +5 -1
  81. package/src/prebid.js +19 -21
  82. package/src/secureCreatives.js +131 -47
  83. package/src/targeting.js +3 -2
  84. package/src/utils.js +13 -10
  85. package/test/helpers/syncPromise.js +71 -0
  86. package/test/spec/auctionmanager_spec.js +179 -15
  87. package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
  88. package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
  89. package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
  90. package/test/spec/modules/admanBidAdapter_spec.js +2 -2
  91. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  92. package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
  93. package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
  94. package/test/spec/modules/asealBidAdapter_spec.js +144 -0
  95. package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
  96. package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
  97. package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
  98. package/test/spec/modules/compassBidAdapter_spec.js +1 -0
  99. package/test/spec/modules/conversantBidAdapter_spec.js +54 -2
  100. package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
  101. package/test/spec/modules/criteoIdSystem_spec.js +6 -3
  102. package/test/spec/modules/currency_spec.js +21 -6
  103. package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
  104. package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
  105. package/test/spec/modules/eids_spec.js +15 -0
  106. package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
  107. package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
  108. package/test/spec/modules/gumgumBidAdapter_spec.js +46 -0
  109. package/test/spec/modules/idImportLibrary_spec.js +197 -10
  110. package/test/spec/modules/improvedigitalBidAdapter_spec.js +61 -0
  111. package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
  112. package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
  113. package/test/spec/modules/loglyliftBidAdapter_spec.js +1 -1
  114. package/test/spec/modules/lunamediahbBidAdapter_spec.js +27 -1
  115. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +1 -1
  116. package/test/spec/modules/oguryBidAdapter_spec.js +69 -3
  117. package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
  118. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
  119. package/test/spec/modules/realTimeDataModule_spec.js +67 -5
  120. package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
  121. package/test/spec/modules/riseBidAdapter_spec.js +31 -5
  122. package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
  123. package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +61 -1
  124. package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
  125. package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
  126. package/test/spec/modules/sortableAnalyticsAdapter_spec.js +2 -3
  127. package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
  128. package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
  129. package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
  130. package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
  131. package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
  132. package/test/spec/modules/userId_spec.js +68 -19
  133. package/test/spec/modules/viewability_spec.js +280 -0
  134. package/test/spec/modules/weboramaRtdProvider_spec.js +536 -20
  135. package/test/spec/modules/welectBidAdapter_spec.js +211 -0
  136. package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
  137. package/test/spec/unit/core/bidderSettings_spec.js +123 -0
  138. package/test/spec/unit/pbjs_api_spec.js +21 -8
  139. package/test/spec/unit/secureCreatives_spec.js +143 -24
@@ -2,6 +2,7 @@ import {expect} from 'chai';
2
2
  import {spec, storage} from 'modules/conversantBidAdapter.js';
3
3
  import * as utils from 'src/utils.js';
4
4
  import {createEidsArray} from 'modules/userId/eids.js';
5
+ import { config } from '../../../src/config.js';
5
6
 
6
7
  describe('Conversant adapter tests', function() {
7
8
  const siteId = '108060';
@@ -119,7 +120,34 @@ describe('Conversant adapter tests', function() {
119
120
  bidId: 'bid005',
120
121
  bidderRequestId: '117d765b87bed38',
121
122
  auctionId: 'req000'
122
- }];
123
+ },
124
+ // video with first party data
125
+ {
126
+ bidder: 'conversant',
127
+ params: {
128
+ site_id: siteId
129
+ },
130
+ mediaTypes: {
131
+ video: {
132
+ context: 'instream',
133
+ mimes: ['video/mp4', 'video/x-flv']
134
+ }
135
+ },
136
+ ortb2Imp: {
137
+ instl: 1,
138
+ ext: {
139
+ data: {
140
+ pbadslot: 'homepage-top-rect'
141
+ }
142
+ }
143
+ },
144
+ placementCode: 'pcode006',
145
+ transactionId: 'tx006',
146
+ bidId: 'bid006',
147
+ bidderRequestId: '117d765b87bed38',
148
+ auctionId: 'req000'
149
+ }
150
+ ];
123
151
 
124
152
  const bidResponses = {
125
153
  body: {
@@ -216,7 +244,7 @@ describe('Conversant adapter tests', function() {
216
244
  expect(payload).to.have.property('id', 'req000');
217
245
  expect(payload).to.have.property('at', 1);
218
246
  expect(payload).to.have.property('imp');
219
- expect(payload.imp).to.be.an('array').with.lengthOf(6);
247
+ expect(payload.imp).to.be.an('array').with.lengthOf(7);
220
248
 
221
249
  expect(payload.imp[0]).to.have.property('id', 'bid000');
222
250
  expect(payload.imp[0]).to.have.property('secure', 1);
@@ -306,6 +334,16 @@ describe('Conversant adapter tests', function() {
306
334
  expect(payload.imp[5].video).to.not.have.property('maxduration');
307
335
  expect(payload.imp[5]).to.not.have.property('banner');
308
336
 
337
+ expect(payload.imp[6]).to.have.property('id', 'bid006');
338
+ expect(payload.imp[6]).to.have.property('video');
339
+ expect(payload.imp[6].video).to.have.property('mimes');
340
+ expect(payload.imp[6].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']);
341
+ expect(payload.imp[6]).to.not.have.property('banner');
342
+ expect(payload.imp[6]).to.have.property('instl');
343
+ expect(payload.imp[6]).to.have.property('ext');
344
+ expect(payload.imp[6].ext).to.have.property('data');
345
+ expect(payload.imp[6].ext.data).to.have.property('pbadslot');
346
+
309
347
  expect(payload).to.have.property('site');
310
348
  expect(payload.site).to.have.property('id', siteId);
311
349
  expect(payload.site).to.have.property('mobile').that.is.oneOf([0, 1]);
@@ -321,6 +359,20 @@ describe('Conversant adapter tests', function() {
321
359
  expect(payload).to.not.have.property('user'); // there should be no user by default
322
360
  });
323
361
 
362
+ it('Verify first party data', () => {
363
+ const bidderRequest = {refererInfo: {referer: 'http://test.com?a=b&c=123'}};
364
+ const cfg = {ortb2: {site: {content: {series: 'MySeries', season: 'MySeason', episode: 3, title: 'MyTitle'}}}};
365
+ config.setConfig(cfg);
366
+ const request = spec.buildRequests(bidRequests, bidderRequest);
367
+ const payload = request.data;
368
+ expect(payload.site).to.have.property('content');
369
+ expect(payload.site.content).to.have.property('series');
370
+ expect(payload.site.content).to.have.property('season');
371
+ expect(payload.site.content).to.have.property('episode');
372
+ expect(payload.site.content).to.have.property('title');
373
+ config.resetConfig();
374
+ });
375
+
324
376
  it('Verify override url', function() {
325
377
  const testUrl = 'https://someurl?name=value';
326
378
  const request = spec.buildRequests([{params: {white_label_url: testUrl}}]);
@@ -663,6 +663,27 @@ describe('The Criteo bidding adapter', function () {
663
663
  expect(request.data.user.uspIab).to.equal('1YNY');
664
664
  });
665
665
 
666
+ it('should properly build a request with schain object', function () {
667
+ const expectedSchain = {
668
+ someProperty: 'someValue'
669
+ };
670
+ const bidRequests = [
671
+ {
672
+ bidder: 'criteo',
673
+ schain: expectedSchain,
674
+ adUnitCode: 'bid-123',
675
+ transactionId: 'transaction-123',
676
+ sizes: [[728, 90]],
677
+ params: {
678
+ zoneId: 123,
679
+ },
680
+ },
681
+ ];
682
+
683
+ const request = spec.buildRequests(bidRequests, bidderRequest);
684
+ expect(request.data.source.ext.schain).to.equal(expectedSchain);
685
+ });
686
+
666
687
  it('should properly build a request with if ccpa consent field is not provided', function () {
667
688
  const bidRequests = [
668
689
  {
@@ -116,16 +116,19 @@ describe('CriteoId module', function () {
116
116
  expect(setCookieStub.calledWith('cto_bundle')).to.be.false;
117
117
  expect(setLocalStorageStub.calledWith('cto_bundle')).to.be.false;
118
118
  } else if (response.bundle) {
119
- expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs)).to.be.true;
119
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.com')).to.be.true;
120
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.testdev.com')).to.be.true;
120
121
  expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.true;
121
122
  expect(triggerPixelStub.called).to.be.false;
122
123
  }
123
124
 
124
125
  if (response.bidId) {
125
- expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs)).to.be.true;
126
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.com')).to.be.true;
127
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.testdev.com')).to.be.true;
126
128
  expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.true;
127
129
  } else {
128
- expect(setCookieStub.calledWith('cto_bidid', '', pastDateString)).to.be.true;
130
+ expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.com')).to.be.true;
131
+ expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.testdev.com')).to.be.true;
129
132
  expect(removeFromLocalStorageStub.calledWith('cto_bidid')).to.be.true;
130
133
  }
131
134
  });
@@ -9,7 +9,8 @@ import {
9
9
  setConfig,
10
10
  addBidResponseHook,
11
11
  currencySupportEnabled,
12
- currencyRates
12
+ currencyRates,
13
+ ready
13
14
  } from 'modules/currency.js';
14
15
 
15
16
  var assert = require('chai').assert;
@@ -24,6 +25,7 @@ describe('currency', function () {
24
25
 
25
26
  beforeEach(function () {
26
27
  fakeCurrencyFileServer = sinon.fakeServer.create();
28
+ ready.reset();
27
29
  });
28
30
 
29
31
  afterEach(function () {
@@ -286,7 +288,7 @@ describe('currency', function () {
286
288
  });
287
289
 
288
290
  describe('currency.addBidResponseDecorator bidResponseQueue', function () {
289
- it('not run until currency rates file is loaded', function () {
291
+ it('not run until currency rates file is loaded', function (done) {
290
292
  setConfig({});
291
293
 
292
294
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
@@ -296,14 +298,27 @@ describe('currency', function () {
296
298
  setConfig({ 'adServerCurrency': 'JPY' });
297
299
 
298
300
  var marker = false;
299
- addBidResponseHook(function() {
301
+ let promiseResolved = false;
302
+ addBidResponseHook(Object.assign(function() {
300
303
  marker = true;
301
- }, 'elementId', bid);
304
+ }, {
305
+ bail: function (promise) {
306
+ promise.then(() => promiseResolved = true);
307
+ }
308
+ }), 'elementId', bid);
302
309
 
303
310
  expect(marker).to.equal(false);
304
311
 
305
- fakeCurrencyFileServer.respond();
306
- expect(marker).to.equal(true);
312
+ setTimeout(() => {
313
+ expect(promiseResolved).to.be.false;
314
+ fakeCurrencyFileServer.respond();
315
+
316
+ setTimeout(() => {
317
+ expect(marker).to.equal(true);
318
+ expect(promiseResolved).to.be.true;
319
+ done();
320
+ });
321
+ });
307
322
  });
308
323
  });
309
324
 
@@ -0,0 +1,239 @@
1
+ import { expect } from 'chai'
2
+ import {spec} from 'modules/displayioBidAdapter.js'
3
+
4
+ describe('Displayio adapter', function () {
5
+ const BIDDER = 'displayio'
6
+ const bidRequests = [{
7
+ bidId: 'bidId_001',
8
+ bidder: BIDDER,
9
+ adUnitCode: 'adUnit_001',
10
+ auctionId: 'auctionId_001',
11
+ bidderRequestId: 'bidderRequestId_001',
12
+ mediaTypes: {
13
+ banner: {
14
+ sizes: [[320, 480]]
15
+ },
16
+ video: {
17
+ sizes: [[360, 640]]
18
+ },
19
+ },
20
+ params: {
21
+ siteId: 1,
22
+ placementId: 1,
23
+ adsSrvDomain: 'adsSrvDomain',
24
+ cdnDomain: 'cdnDomain',
25
+ }
26
+ }]
27
+ const bidderRequest = {
28
+ refererInfo: {
29
+ referer: 'testprebid.com'
30
+ }
31
+ }
32
+
33
+ describe('isBidRequestValid', function () {
34
+ it('should return true when required params found', function() {
35
+ const validBid = spec.isBidRequestValid(bidRequests[0])
36
+ expect(validBid).to.be.true
37
+ })
38
+
39
+ const bidRequestsNoParams = [{
40
+ bidder: BIDDER,
41
+ }]
42
+ it('should not validate without params', function () {
43
+ const request = spec.isBidRequestValid(bidRequestsNoParams, bidderRequest)
44
+ expect(request).to.be.false
45
+ })
46
+
47
+ const noSiteId = {
48
+ bidder: BIDDER,
49
+ params: {
50
+ placementId: 1,
51
+ adsSrvDomain: 'adsSrvDomain',
52
+ cdnDomain: 'cdnDomain',
53
+ }
54
+ }
55
+ it('should not validate without siteId', function() {
56
+ const invalidBid = spec.isBidRequestValid(noSiteId)
57
+ expect(invalidBid).to.be.false
58
+ })
59
+
60
+ const noPlacementId = {
61
+ bidder: BIDDER,
62
+ params: {
63
+ siteId: 1,
64
+ adsSrvDomain: 'adsSrvDomain',
65
+ cdnDomain: 'cdnDomain',
66
+ }
67
+ }
68
+ it('should not validate without placementId', function() {
69
+ const invalidBid = spec.isBidRequestValid(noPlacementId)
70
+ expect(invalidBid).to.be.false
71
+ })
72
+
73
+ const noAdsSrvDomain = {
74
+ bidder: BIDDER,
75
+ params: {
76
+ siteId: 1,
77
+ placementId: 1,
78
+ cdnDomain: 'cdnDomain',
79
+ }
80
+ }
81
+ it('should not validate without adsSrvDomain', function() {
82
+ const invalidBid = spec.isBidRequestValid(noAdsSrvDomain)
83
+ expect(invalidBid).to.be.false
84
+ })
85
+
86
+ const noCdnDomain = {
87
+ bidder: BIDDER,
88
+ params: {
89
+ siteId: 1,
90
+ placementId: 1,
91
+ adsSrvDomain: 'adsSrvDomain',
92
+ }
93
+ }
94
+ it('should not validate without cdnDomain', function() {
95
+ const invalidBid = spec.isBidRequestValid(noCdnDomain)
96
+ expect(invalidBid).to.be.false
97
+ })
98
+ })
99
+
100
+ describe('buildRequests', function () {
101
+ it('should build request', function() {
102
+ const request = spec.buildRequests(bidRequests, bidderRequest)
103
+ expect(request).to.not.be.empty
104
+ })
105
+
106
+ it('sends bid request to the endpoint via POST', function () {
107
+ const request = spec.buildRequests(bidRequests, bidderRequest)
108
+ expect(request[0].method).to.equal('POST')
109
+ })
110
+
111
+ it('sends all bid parameters', function () {
112
+ const request = spec.buildRequests(bidRequests, bidderRequest)
113
+ expect(request[0]).to.have.keys(['headers', 'data', 'method', 'url'])
114
+ })
115
+
116
+ it('should not crash when there is no media types', function () {
117
+ const bidRequestsNoMediaTypes = [{
118
+ bidder: BIDDER,
119
+ params: {
120
+ siteId: 1,
121
+ placementId: 1,
122
+ adsSrvDomain: 'adsSrvDomain',
123
+ cdnDomain: 'cdnDomain',
124
+ }
125
+ }]
126
+ const request = spec.buildRequests(bidRequestsNoMediaTypes, bidderRequest)
127
+ expect(request[0]).to.have.keys(['headers', 'data', 'method', 'url'])
128
+ })
129
+ })
130
+
131
+ describe('_getPayload', function () {
132
+ const payload = spec._getPayload(bidRequests[0], bidderRequest)
133
+ it('should not be empty', function() {
134
+ expect(payload).to.not.be.empty
135
+ })
136
+
137
+ it('should have userSession', function() {
138
+ expect(payload.userSession).to.be.a('string')
139
+ })
140
+
141
+ it('should have data object', function() {
142
+ expect(payload.data).to.be.a('object')
143
+ })
144
+
145
+ it('should have complianceData object', function() {
146
+ expect(payload.data.complianceData).to.be.a('object')
147
+ })
148
+
149
+ it('should have device object', function() {
150
+ expect(payload.data.device).to.be.a('object')
151
+ })
152
+
153
+ it('should have omidpn', function() {
154
+ expect(payload.data.omidpn).to.be.a('string')
155
+ })
156
+
157
+ it('should have integration', function() {
158
+ expect(payload.data.integration).to.be.a('string')
159
+ })
160
+
161
+ it('should have bidId', function() {
162
+ expect(payload.data.id).to.not.be.empty
163
+ })
164
+
165
+ it('should have action getPlacement', function() {
166
+ expect(payload.data.action).to.be.equal('getPlacement')
167
+ })
168
+
169
+ it('should have app parameter', function() {
170
+ expect(payload.data.app).to.be.a('number')
171
+ })
172
+
173
+ it('should have placement parameter', function() {
174
+ expect(payload.data.placement).to.be.a('number')
175
+ })
176
+ })
177
+
178
+ describe('interpretResponse', function () {
179
+ const response = {
180
+ body: {
181
+ status: 'ok',
182
+ data: {
183
+ ads: [{
184
+ ad: {
185
+ data: {
186
+ id: '001',
187
+ ecpm: 100,
188
+ w: 32,
189
+ h: 480,
190
+ markup: 'test ad'
191
+ }
192
+ },
193
+ subtype: 'html'
194
+ }],
195
+ }
196
+ }
197
+ }
198
+ const serverRequest = {
199
+ data: {
200
+ data: {
201
+ id: 'id_001',
202
+ data: {
203
+ ref: 'testprebid.com'
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ let ir = spec.interpretResponse(response, serverRequest)
210
+
211
+ expect(ir.length).to.equal(1)
212
+
213
+ ir = ir[0]
214
+
215
+ it('should have requestId', function() {
216
+ expect(ir.requestId).to.be.a('string')
217
+ })
218
+
219
+ it('should have cpm', function() {
220
+ expect(ir.cpm).to.be.a('number')
221
+ })
222
+
223
+ it('should have width', function() {
224
+ expect(ir.width).to.be.a('number')
225
+ })
226
+
227
+ it('should have height', function() {
228
+ expect(ir.height).to.be.a('number')
229
+ })
230
+
231
+ it('should have creativeId', function() {
232
+ expect(ir.creativeId).to.be.a('number')
233
+ })
234
+
235
+ it('should have ad', function() {
236
+ expect(ir.ad).to.be.a('string')
237
+ })
238
+ })
239
+ })
@@ -0,0 +1,242 @@
1
+ import {expect} from 'chai';
2
+ import {spec} from '../../../modules/e_volutionBidAdapter.js';
3
+
4
+ describe('EvolutionTechBidAdapter', function () {
5
+ let bid = {
6
+ bidId: '23fhj33i987f',
7
+ bidder: 'e_volution',
8
+ params: {
9
+ placementId: 0
10
+ },
11
+ mediaTypes: {
12
+ banner: {
13
+ sizes: [[300, 250]],
14
+ }
15
+ }
16
+ };
17
+
18
+ describe('isBidRequestValid', function () {
19
+ it('Should return true if there are bidId, params and placementId parameters present', function () {
20
+ expect(spec.isBidRequestValid(bid)).to.be.true;
21
+ });
22
+ it('Should return false if at least one of parameters is not present', function () {
23
+ delete bid.params.placementId;
24
+ expect(spec.isBidRequestValid(bid)).to.be.false;
25
+ });
26
+ });
27
+
28
+ describe('buildRequests', function () {
29
+ let serverRequest = spec.buildRequests([bid]);
30
+ it('Creates a ServerRequest object with method, URL and data', function () {
31
+ expect(serverRequest).to.exist;
32
+ expect(serverRequest.method).to.exist;
33
+ expect(serverRequest.url).to.exist;
34
+ expect(serverRequest.data).to.exist;
35
+ });
36
+ it('Returns POST method', function () {
37
+ expect(serverRequest.method).to.equal('POST');
38
+ });
39
+ it('Returns valid URL', function () {
40
+ expect(serverRequest.url).to.equal('https://service.e-volution.ai/?c=o&m=multi');
41
+ });
42
+ it('Returns valid data if array of bids is valid', function () {
43
+ let data = serverRequest.data;
44
+ expect(data).to.be.an('object');
45
+ expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements');
46
+ expect(data.deviceWidth).to.be.a('number');
47
+ expect(data.deviceHeight).to.be.a('number');
48
+ expect(data.language).to.be.a('string');
49
+ expect(data.secure).to.be.within(0, 1);
50
+ expect(data.host).to.be.a('string');
51
+ expect(data.page).to.be.a('string');
52
+ let placement = data['placements'][0];
53
+ expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'bidfloor');
54
+ expect(placement.placementId).to.equal(0);
55
+ expect(placement.bidId).to.equal('23fhj33i987f');
56
+ expect(placement.traffic).to.equal('banner');
57
+ });
58
+ it('Returns empty data if no valid requests are passed', function () {
59
+ serverRequest = spec.buildRequests([]);
60
+ let data = serverRequest.data;
61
+ expect(data.placements).to.be.an('array').that.is.empty;
62
+ });
63
+ });
64
+ describe('interpretResponse', function () {
65
+ it('Should interpret banner response', function () {
66
+ const banner = {
67
+ body: [{
68
+ mediaType: 'banner',
69
+ width: 300,
70
+ height: 250,
71
+ cpm: 0.4,
72
+ ad: 'Test',
73
+ requestId: '23fhj33i987f',
74
+ ttl: 120,
75
+ creativeId: '2',
76
+ netRevenue: true,
77
+ currency: 'USD',
78
+ dealId: '1',
79
+ meta: {}
80
+ }]
81
+ };
82
+ let bannerResponses = spec.interpretResponse(banner);
83
+ expect(bannerResponses).to.be.an('array').that.is.not.empty;
84
+ let dataItem = bannerResponses[0];
85
+ expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId',
86
+ 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
87
+ expect(dataItem.requestId).to.equal('23fhj33i987f');
88
+ expect(dataItem.cpm).to.equal(0.4);
89
+ expect(dataItem.width).to.equal(300);
90
+ expect(dataItem.height).to.equal(250);
91
+ expect(dataItem.ad).to.equal('Test');
92
+ expect(dataItem.ttl).to.equal(120);
93
+ expect(dataItem.creativeId).to.equal('2');
94
+ expect(dataItem.netRevenue).to.be.true;
95
+ expect(dataItem.currency).to.equal('USD');
96
+ });
97
+ it('Should interpret video response', function () {
98
+ const video = {
99
+ body: [{
100
+ vastUrl: 'test.com',
101
+ mediaType: 'video',
102
+ cpm: 0.5,
103
+ requestId: '23fhj33i987f',
104
+ ttl: 120,
105
+ creativeId: '2',
106
+ netRevenue: true,
107
+ currency: 'USD',
108
+ dealId: '1',
109
+ meta: {}
110
+ }]
111
+ };
112
+ let videoResponses = spec.interpretResponse(video);
113
+ expect(videoResponses).to.be.an('array').that.is.not.empty;
114
+
115
+ let dataItem = videoResponses[0];
116
+ expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId',
117
+ 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta');
118
+ expect(dataItem.requestId).to.equal('23fhj33i987f');
119
+ expect(dataItem.cpm).to.equal(0.5);
120
+ expect(dataItem.vastUrl).to.equal('test.com');
121
+ expect(dataItem.ttl).to.equal(120);
122
+ expect(dataItem.creativeId).to.equal('2');
123
+ expect(dataItem.netRevenue).to.be.true;
124
+ expect(dataItem.currency).to.equal('USD');
125
+ });
126
+ it('Should interpret native response', function () {
127
+ const native = {
128
+ body: [{
129
+ mediaType: 'native',
130
+ native: {
131
+ clickUrl: 'test.com',
132
+ title: 'Test',
133
+ image: 'test.com',
134
+ impressionTrackers: ['test.com'],
135
+ },
136
+ ttl: 120,
137
+ cpm: 0.4,
138
+ requestId: '23fhj33i987f',
139
+ creativeId: '2',
140
+ netRevenue: true,
141
+ currency: 'USD',
142
+ meta: {}
143
+ }]
144
+ };
145
+ let nativeResponses = spec.interpretResponse(native);
146
+ expect(nativeResponses).to.be.an('array').that.is.not.empty;
147
+
148
+ let dataItem = nativeResponses[0];
149
+ expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta');
150
+ expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image')
151
+ expect(dataItem.requestId).to.equal('23fhj33i987f');
152
+ expect(dataItem.cpm).to.equal(0.4);
153
+ expect(dataItem.native.clickUrl).to.equal('test.com');
154
+ expect(dataItem.native.title).to.equal('Test');
155
+ expect(dataItem.native.image).to.equal('test.com');
156
+ expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty;
157
+ expect(dataItem.native.impressionTrackers[0]).to.equal('test.com');
158
+ expect(dataItem.ttl).to.equal(120);
159
+ expect(dataItem.creativeId).to.equal('2');
160
+ expect(dataItem.netRevenue).to.be.true;
161
+ expect(dataItem.currency).to.equal('USD');
162
+ });
163
+ it('Should return an empty array if invalid banner response is passed', function () {
164
+ const invBanner = {
165
+ body: [{
166
+ width: 300,
167
+ cpm: 0.4,
168
+ ad: 'Test',
169
+ requestId: '23fhj33i987f',
170
+ ttl: 120,
171
+ creativeId: '2',
172
+ netRevenue: true,
173
+ currency: 'USD',
174
+ dealId: '1'
175
+ }]
176
+ };
177
+
178
+ let serverResponses = spec.interpretResponse(invBanner);
179
+ expect(serverResponses).to.be.an('array').that.is.empty;
180
+ });
181
+ it('Should return an empty array if invalid video response is passed', function () {
182
+ const invVideo = {
183
+ body: [{
184
+ mediaType: 'video',
185
+ cpm: 0.5,
186
+ requestId: '23fhj33i987f',
187
+ ttl: 120,
188
+ creativeId: '2',
189
+ netRevenue: true,
190
+ currency: 'USD',
191
+ dealId: '1'
192
+ }]
193
+ };
194
+ let serverResponses = spec.interpretResponse(invVideo);
195
+ expect(serverResponses).to.be.an('array').that.is.empty;
196
+ });
197
+ it('Should return an empty array if invalid native response is passed', function () {
198
+ const invNative = {
199
+ body: [{
200
+ mediaType: 'native',
201
+ clickUrl: 'test.com',
202
+ title: 'Test',
203
+ impressionTrackers: ['test.com'],
204
+ ttl: 120,
205
+ requestId: '23fhj33i987f',
206
+ creativeId: '2',
207
+ netRevenue: true,
208
+ currency: 'USD',
209
+ }]
210
+ };
211
+ let serverResponses = spec.interpretResponse(invNative);
212
+ expect(serverResponses).to.be.an('array').that.is.empty;
213
+ });
214
+ it('Should return an empty array if invalid response is passed', function () {
215
+ const invalid = {
216
+ body: [{
217
+ ttl: 120,
218
+ creativeId: '2',
219
+ netRevenue: true,
220
+ currency: 'USD',
221
+ dealId: '1'
222
+ }]
223
+ };
224
+ let serverResponses = spec.interpretResponse(invalid);
225
+ expect(serverResponses).to.be.an('array').that.is.empty;
226
+ });
227
+ });
228
+ describe('getUserSyncs', function () {
229
+ let userSync = spec.getUserSyncs();
230
+ it('Returns valid URL and type', function () {
231
+ if (spec.noSync) {
232
+ expect(userSync).to.be.equal(false);
233
+ } else {
234
+ expect(userSync).to.be.an('array').with.lengthOf(1);
235
+ expect(userSync[0].type).to.exist;
236
+ expect(userSync[0].url).to.exist;
237
+ expect(userSync[0].type).to.be.equal('image');
238
+ expect(userSync[0].url).to.be.equal('https://service.e-volution.ai/?c=o&m=sync');
239
+ }
240
+ });
241
+ });
242
+ });