prebid.js 6.7.0 → 6.11.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 (160) hide show
  1. package/.eslintrc.js +8 -1
  2. package/integrationExamples/gpt/{haloRtdProvider_example.html → hadronRtdProvider_example.html} +9 -9
  3. package/integrationExamples/gpt/idImportLibrary_example.html +2 -2
  4. package/integrationExamples/gpt/userId_example.html +2 -2
  5. package/integrationExamples/gpt/weboramaRtdProvider_example.html +154 -115
  6. package/integrationExamples/gpt/x-domain/creative.html +63 -29
  7. package/modules/.submodules.json +3 -0
  8. package/modules/adagioBidAdapter.js +0 -8
  9. package/modules/adagioBidAdapter.md +1 -1
  10. package/modules/adkernelBidAdapter.js +2 -1
  11. package/modules/adnuntiusRtdProvider.js +96 -0
  12. package/modules/adnuntiusRtdProvider.md +41 -0
  13. package/modules/adotBidAdapter.js +516 -567
  14. package/modules/adotBidAdapter.md +6 -44
  15. package/modules/adpod.js +12 -14
  16. package/modules/adyoulikeBidAdapter.js +2 -0
  17. package/modules/appnexusBidAdapter.js +14 -2
  18. package/modules/asealBidAdapter.js +58 -0
  19. package/modules/asealBidAdapter.md +52 -0
  20. package/modules/brandmetricsRtdProvider.js +168 -0
  21. package/modules/brandmetricsRtdProvider.md +40 -0
  22. package/modules/conversantBidAdapter.js +7 -0
  23. package/modules/criteoBidAdapter.js +9 -0
  24. package/modules/currency.js +27 -5
  25. package/modules/displayioBidAdapter.js +157 -0
  26. package/modules/displayioBidAdapter.md +148 -0
  27. package/modules/dspxBidAdapter.js +69 -29
  28. package/modules/dspxBidAdapter.md +2 -1
  29. package/modules/e_volutionBidAdapter.js +158 -0
  30. package/modules/gridBidAdapter.js +15 -1
  31. package/modules/gumgumBidAdapter.js +52 -38
  32. package/modules/hadronIdSystem.js +96 -0
  33. package/modules/hadronIdSystem.md +35 -0
  34. package/modules/hadronRtdProvider.js +254 -0
  35. package/modules/hadronRtdProvider.md +126 -0
  36. package/modules/haloIdSystem.md +4 -35
  37. package/modules/haloRtdProvider.md +3 -126
  38. package/modules/imRtdProvider.js +10 -0
  39. package/modules/improvedigitalBidAdapter.js +5 -0
  40. package/modules/interactiveOffersBidAdapter.js +9 -6
  41. package/modules/iqzoneBidAdapter.js +10 -3
  42. package/modules/iqzoneBidAdapter.md +16 -0
  43. package/modules/ixBidAdapter.js +2 -6
  44. package/modules/kubientBidAdapter.js +50 -19
  45. package/modules/lunamediahbBidAdapter.js +32 -4
  46. package/modules/malltvBidAdapter.js +7 -3
  47. package/modules/malltvBidAdapter.md +64 -51
  48. package/modules/mass.js +3 -5
  49. package/modules/mediakeysBidAdapter.js +0 -5
  50. package/modules/medianetAnalyticsAdapter.js +1 -1
  51. package/modules/mediasquareBidAdapter.js +9 -1
  52. package/modules/nextMillenniumBidAdapter.js +1 -0
  53. package/modules/oguryBidAdapter.js +7 -14
  54. package/modules/prebidServerBidAdapter/index.js +61 -39
  55. package/modules/priceFloors.js +20 -12
  56. package/modules/pubmaticBidAdapter.js +1 -1
  57. package/modules/richaudienceBidAdapter.js +8 -3
  58. package/modules/riseBidAdapter.js +17 -6
  59. package/modules/rtbhouseBidAdapter.js +2 -0
  60. package/modules/rubiconAnalyticsAdapter.js +5 -0
  61. package/modules/rubiconBidAdapter.js +2 -2
  62. package/modules/sizeMappingV2.js +1 -8
  63. package/modules/sortableAnalyticsAdapter.js +5 -4
  64. package/modules/sovrnBidAdapter.js +93 -18
  65. package/modules/sovrnBidAdapter.md +80 -2
  66. package/modules/sspBCBidAdapter.js +53 -20
  67. package/modules/telariaBidAdapter.js +22 -29
  68. package/modules/trustpidSystem.js +197 -0
  69. package/modules/trustpidSystem.md +45 -0
  70. package/modules/undertoneBidAdapter.js +17 -1
  71. package/modules/userId/eids.js +16 -1
  72. package/modules/userId/eids.md +10 -2
  73. package/modules/userId/userId.md +17 -2
  74. package/modules/vibrantmediaBidAdapter.js +220 -0
  75. package/modules/vibrantmediaBidAdapter.md +92 -0
  76. package/modules/vidoomyBidAdapter.js +8 -0
  77. package/modules/vidoomyBidAdapter.md +4 -2
  78. package/modules/weboramaRtdProvider.js +264 -34
  79. package/modules/weboramaRtdProvider.md +110 -40
  80. package/modules/yahoosspBidAdapter.js +3 -1
  81. package/modules/yieldoneBidAdapter.js +6 -0
  82. package/package.json +2 -1
  83. package/src/adRendering.js +38 -0
  84. package/src/adapterManager.js +24 -19
  85. package/src/adapters/bidderFactory.js +14 -11
  86. package/src/adloader.js +2 -1
  87. package/src/auction.js +138 -115
  88. package/src/auctionIndex.js +85 -0
  89. package/src/auctionManager.js +3 -0
  90. package/src/bidderSettings.js +69 -0
  91. package/src/bidfactory.js +18 -6
  92. package/src/native.js +29 -21
  93. package/src/prebid.js +3 -19
  94. package/src/secureCreatives.js +128 -45
  95. package/src/targeting.js +11 -2
  96. package/src/utils.js +14 -17
  97. package/src/video.js +10 -11
  98. package/src/videoCache.js +10 -9
  99. package/test/fixtures/fixtures.js +2 -1
  100. package/test/helpers/indexStub.js +28 -0
  101. package/test/helpers/syncPromise.js +71 -0
  102. package/test/spec/auctionmanager_spec.js +268 -89
  103. package/test/spec/config_spec.js +24 -1
  104. package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
  105. package/test/spec/modules/adnuntiusRtdProvider_spec.js +145 -0
  106. package/test/spec/modules/adotBidAdapter_spec.js +294 -3124
  107. package/test/spec/modules/adpod_spec.js +91 -156
  108. package/test/spec/modules/adyoulikeBidAdapter_spec.js +4 -0
  109. package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
  110. package/test/spec/modules/asealBidAdapter_spec.js +144 -0
  111. package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
  112. package/test/spec/modules/conversantBidAdapter_spec.js +54 -2
  113. package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
  114. package/test/spec/modules/currency_spec.js +36 -15
  115. package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
  116. package/test/spec/modules/dspxBidAdapter_spec.js +20 -15
  117. package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
  118. package/test/spec/modules/eids_spec.js +2 -2
  119. package/test/spec/modules/gridBidAdapter_spec.js +18 -0
  120. package/test/spec/modules/gumgumBidAdapter_spec.js +49 -3
  121. package/test/spec/modules/hadronIdSystem_spec.js +57 -0
  122. package/test/spec/modules/hadronRtdProvider_spec.js +762 -0
  123. package/test/spec/modules/imRtdProvider_spec.js +30 -1
  124. package/test/spec/modules/improvedigitalBidAdapter_spec.js +19 -0
  125. package/test/spec/modules/iqzoneBidAdapter_spec.js +1 -0
  126. package/test/spec/modules/ixBidAdapter_spec.js +1 -1
  127. package/test/spec/modules/kubientBidAdapter_spec.js +182 -84
  128. package/test/spec/modules/lunamediahbBidAdapter_spec.js +27 -1
  129. package/test/spec/modules/mass_spec.js +2 -14
  130. package/test/spec/modules/mediakeysBidAdapter_spec.js +9 -5
  131. package/test/spec/modules/mediasquareBidAdapter_spec.js +25 -1
  132. package/test/spec/modules/oguryBidAdapter_spec.js +63 -5
  133. package/test/spec/modules/prebidServerBidAdapter_spec.js +43 -6
  134. package/test/spec/modules/priceFloors_spec.js +83 -24
  135. package/test/spec/modules/pubmaticBidAdapter_spec.js +40 -0
  136. package/test/spec/modules/riseBidAdapter_spec.js +30 -4
  137. package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +31 -1
  138. package/test/spec/modules/rubiconBidAdapter_spec.js +1 -1
  139. package/test/spec/modules/sortableAnalyticsAdapter_spec.js +2 -3
  140. package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
  141. package/test/spec/modules/sspBCBidAdapter_spec.js +7 -7
  142. package/test/spec/modules/telariaBidAdapter_spec.js +1 -3
  143. package/test/spec/modules/trustpidSystem_spec.js +232 -0
  144. package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
  145. package/test/spec/modules/userId_spec.js +39 -39
  146. package/test/spec/modules/vibrantmediaBidAdapter_spec.js +1237 -0
  147. package/test/spec/modules/vidoomyBidAdapter_spec.js +7 -1
  148. package/test/spec/modules/weboramaRtdProvider_spec.js +536 -20
  149. package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
  150. package/test/spec/modules/yieldoneBidAdapter_spec.js +33 -0
  151. package/test/spec/native_spec.js +62 -40
  152. package/test/spec/unit/core/adapterManager_spec.js +22 -0
  153. package/test/spec/unit/core/auctionIndex_spec.js +129 -0
  154. package/test/spec/unit/core/bidderFactory_spec.js +65 -12
  155. package/test/spec/unit/core/bidderSettings_spec.js +123 -0
  156. package/test/spec/unit/core/targeting_spec.js +93 -0
  157. package/test/spec/unit/pbjs_api_spec.js +80 -42
  158. package/test/spec/unit/secureCreatives_spec.js +143 -24
  159. package/test/spec/videoCache_spec.js +18 -19
  160. package/test/spec/video_spec.js +51 -61
@@ -0,0 +1,191 @@
1
+ import * as brandmetricsRTD from '../../../modules/brandmetricsRtdProvider.js';
2
+ import {config} from 'src/config.js';
3
+
4
+ const VALID_CONFIG = {
5
+ name: 'brandmetrics',
6
+ waitForIt: true,
7
+ params: {
8
+ scriptId: '00000000-0000-0000-0000-000000000000',
9
+ bidders: ['ozone']
10
+ }
11
+ };
12
+
13
+ const NO_BIDDERS_CONFIG = {
14
+ name: 'brandmetrics',
15
+ waitForIt: true,
16
+ params: {
17
+ scriptId: '00000000-0000-0000-0000-000000000000'
18
+ }
19
+ };
20
+
21
+ const NO_SCRIPTID_CONFIG = {
22
+ name: 'brandmetrics',
23
+ waitForIt: true
24
+ };
25
+
26
+ const USER_CONSENT = {
27
+ gdpr: {
28
+ vendorData: {
29
+ vendor: {
30
+ consents: {
31
+ 422: true
32
+ }
33
+ },
34
+ purpose: {
35
+ consents: {
36
+ 1: true,
37
+ 7: true
38
+ }
39
+ }
40
+ },
41
+ gdprApplies: true
42
+ }
43
+ };
44
+
45
+ const NO_TCF_CONSENT = {
46
+ gdpr: {
47
+ vendorData: {
48
+ vendor: {
49
+ consents: {
50
+ 422: false
51
+ }
52
+ },
53
+ purpose: {
54
+ consents: {
55
+ 1: false,
56
+ 7: false
57
+ }
58
+ }
59
+ },
60
+ gdprApplies: true
61
+ }
62
+ };
63
+
64
+ const NO_USP_CONSENT = {
65
+ usp: '1NYY'
66
+ };
67
+
68
+ function mockSurveyLoaded(surveyConf) {
69
+ const commands = window._brandmetrics || [];
70
+ commands.forEach(command => {
71
+ if (command.cmd === '_addeventlistener') {
72
+ const conf = command.val;
73
+ if (conf.event === 'surveyloaded') {
74
+ conf.handler(surveyConf);
75
+ }
76
+ }
77
+ });
78
+ }
79
+
80
+ function scriptTagExists(url) {
81
+ const tags = document.getElementsByTagName('script');
82
+ for (let i = 0; i < tags.length; i++) {
83
+ if (tags[i].src === url) {
84
+ return true;
85
+ }
86
+ }
87
+ return false;
88
+ }
89
+
90
+ describe('BrandmetricsRTD module', () => {
91
+ beforeEach(function () {
92
+ const scriptTags = document.getElementsByTagName('script');
93
+ for (let i = 0; i < scriptTags.length; i++) {
94
+ if (scriptTags[i].src.indexOf('brandmetrics') !== -1) {
95
+ scriptTags[i].remove();
96
+ }
97
+ }
98
+ });
99
+
100
+ it('should init and return true', () => {
101
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, USER_CONSENT)).to.equal(true);
102
+ });
103
+
104
+ it('should init and return true even if bidders is not included', () => {
105
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_BIDDERS_CONFIG, USER_CONSENT)).to.equal(true);
106
+ });
107
+
108
+ it('should init even if script- id is not configured', () => {
109
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_SCRIPTID_CONFIG, USER_CONSENT)).to.equal(true);
110
+ });
111
+
112
+ it('should not init when there is no TCF- consent', () => {
113
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_TCF_CONSENT)).to.equal(false);
114
+ });
115
+
116
+ it('should not init when there is no usp- consent', () => {
117
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_USP_CONSENT)).to.equal(false);
118
+ });
119
+ });
120
+
121
+ describe('getBidRequestData', () => {
122
+ beforeEach(function () {
123
+ config.resetConfig()
124
+ })
125
+
126
+ it('should set targeting keys for specified bidders', () => {
127
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {
128
+ const bidderConfig = config.getBidderConfig()
129
+ const expected = VALID_CONFIG.params.bidders
130
+
131
+ expected.forEach(exp => {
132
+ expect(bidderConfig[exp].ortb2.user.ext.data.mockTargetKey).to.equal('mockMeasurementId')
133
+ })
134
+ }, VALID_CONFIG);
135
+
136
+ mockSurveyLoaded({
137
+ available: true,
138
+ conf: {
139
+ displayOption: {
140
+ type: 'pbjs',
141
+ targetKey: 'mockTargetKey'
142
+ }
143
+ },
144
+ survey: {
145
+ measurementId: 'mockMeasurementId'
146
+ }
147
+ });
148
+ });
149
+
150
+ it('should only set targeting keys when the brandmetrics survey- type is "pbjs"', () => {
151
+ mockSurveyLoaded({
152
+ available: true,
153
+ conf: {
154
+ displayOption: {
155
+ type: 'dfp',
156
+ targetKey: 'mockTargetKey'
157
+ }
158
+ },
159
+ survey: {
160
+ measurementId: 'mockMeasurementId'
161
+ }
162
+ });
163
+
164
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG);
165
+ const bidderConfig = config.getBidderConfig()
166
+ expect(Object.keys(bidderConfig).length).to.equal(0)
167
+ });
168
+
169
+ it('should use a default targeting key name if the brandmetrics- configuration does not include one', () => {
170
+ mockSurveyLoaded({
171
+ available: true,
172
+ conf: {
173
+ displayOption: {
174
+ type: 'pbjs',
175
+ }
176
+ },
177
+ survey: {
178
+ measurementId: 'mockMeasurementId'
179
+ }
180
+ });
181
+
182
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG);
183
+
184
+ const bidderConfig = config.getBidderConfig()
185
+ const expected = VALID_CONFIG.params.bidders
186
+
187
+ expected.forEach(exp => {
188
+ expect(bidderConfig[exp].ortb2.user.ext.data.brandmetrics_survey).to.equal('mockMeasurementId')
189
+ })
190
+ });
191
+ });
@@ -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
  {
@@ -9,8 +9,11 @@ import {
9
9
  setConfig,
10
10
  addBidResponseHook,
11
11
  currencySupportEnabled,
12
- currencyRates
12
+ currencyRates,
13
+ ready
13
14
  } from 'modules/currency.js';
15
+ import {createBid} from '../../../src/bidfactory.js';
16
+ import CONSTANTS from '../../../src/constants.json';
14
17
 
15
18
  var assert = require('chai').assert;
16
19
  var expect = require('chai').expect;
@@ -22,8 +25,13 @@ describe('currency', function () {
22
25
 
23
26
  let fn = sinon.spy();
24
27
 
28
+ function makeBid(bidProps) {
29
+ return Object.assign(createBid(CONSTANTS.STATUS.GOOD), bidProps);
30
+ }
31
+
25
32
  beforeEach(function () {
26
33
  fakeCurrencyFileServer = sinon.fakeServer.create();
34
+ ready.reset();
27
35
  });
28
36
 
29
37
  afterEach(function () {
@@ -286,7 +294,7 @@ describe('currency', function () {
286
294
  });
287
295
 
288
296
  describe('currency.addBidResponseDecorator bidResponseQueue', function () {
289
- it('not run until currency rates file is loaded', function () {
297
+ it('not run until currency rates file is loaded', function (done) {
290
298
  setConfig({});
291
299
 
292
300
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
@@ -296,21 +304,34 @@ describe('currency', function () {
296
304
  setConfig({ 'adServerCurrency': 'JPY' });
297
305
 
298
306
  var marker = false;
299
- addBidResponseHook(function() {
307
+ let promiseResolved = false;
308
+ addBidResponseHook(Object.assign(function() {
300
309
  marker = true;
301
- }, 'elementId', bid);
310
+ }, {
311
+ bail: function (promise) {
312
+ promise.then(() => promiseResolved = true);
313
+ }
314
+ }), 'elementId', bid);
302
315
 
303
316
  expect(marker).to.equal(false);
304
317
 
305
- fakeCurrencyFileServer.respond();
306
- expect(marker).to.equal(true);
318
+ setTimeout(() => {
319
+ expect(promiseResolved).to.be.false;
320
+ fakeCurrencyFileServer.respond();
321
+
322
+ setTimeout(() => {
323
+ expect(marker).to.equal(true);
324
+ expect(promiseResolved).to.be.true;
325
+ done();
326
+ });
327
+ });
307
328
  });
308
329
  });
309
330
 
310
331
  describe('currency.addBidResponseDecorator', function () {
311
332
  it('should leave bid at 1 when currency support is not enabled and fromCurrency is USD', function () {
312
333
  setConfig({});
313
- var bid = { 'cpm': 1, 'currency': 'USD' };
334
+ var bid = makeBid({ 'cpm': 1, 'currency': 'USD' });
314
335
  var innerBid;
315
336
  addBidResponseHook(function(adCodeId, bid) {
316
337
  innerBid = bid;
@@ -321,7 +342,7 @@ describe('currency', function () {
321
342
  it('should result in NO_BID when currency support is not enabled and fromCurrency is not USD', function () {
322
343
  setConfig({});
323
344
 
324
- var bid = { 'cpm': 1, 'currency': 'GBP' };
345
+ var bid = makeBid({ 'cpm': 1, 'currency': 'GBP' });
325
346
  var innerBid;
326
347
  addBidResponseHook(function(adCodeId, bid) {
327
348
  innerBid = bid;
@@ -333,7 +354,7 @@ describe('currency', function () {
333
354
  setConfig({
334
355
  'adServerCurrency': 'USD'
335
356
  });
336
- var bid = { 'cpm': 1, 'currency': 'USD' };
357
+ var bid = makeBid({ 'cpm': 1, 'currency': 'USD' });
337
358
  var innerBid;
338
359
  addBidResponseHook(function(adCodeId, bid) {
339
360
  innerBid = bid;
@@ -348,7 +369,7 @@ describe('currency', function () {
348
369
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
349
370
  setConfig({ 'adServerCurrency': 'JPY' });
350
371
  fakeCurrencyFileServer.respond();
351
- var bid = { 'cpm': 1, 'currency': 'ABC' };
372
+ var bid = makeBid({ 'cpm': 1, 'currency': 'ABC' });
352
373
  var innerBid;
353
374
  addBidResponseHook(function(adCodeId, bid) {
354
375
  innerBid = bid;
@@ -360,7 +381,7 @@ describe('currency', function () {
360
381
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
361
382
  setConfig({ 'adServerCurrency': 'ABC' });
362
383
  fakeCurrencyFileServer.respond();
363
- var bid = { 'cpm': 1, 'currency': 'GBP' };
384
+ var bid = makeBid({ 'cpm': 1, 'currency': 'GBP' });
364
385
  var innerBid;
365
386
  addBidResponseHook(function(adCodeId, bid) {
366
387
  innerBid = bid;
@@ -372,7 +393,7 @@ describe('currency', function () {
372
393
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
373
394
  setConfig({ 'adServerCurrency': 'JPY' });
374
395
  fakeCurrencyFileServer.respond();
375
- var bid = { 'cpm': 1, 'currency': 'JPY' };
396
+ var bid = makeBid({ 'cpm': 1, 'currency': 'JPY' });
376
397
  var innerBid;
377
398
  addBidResponseHook(function(adCodeId, bid) {
378
399
  innerBid = bid;
@@ -385,7 +406,7 @@ describe('currency', function () {
385
406
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
386
407
  setConfig({ 'adServerCurrency': 'GBP' });
387
408
  fakeCurrencyFileServer.respond();
388
- var bid = { 'cpm': 1, 'currency': 'USD' };
409
+ var bid = makeBid({ 'cpm': 1, 'currency': 'USD' });
389
410
  var innerBid;
390
411
  addBidResponseHook(function(adCodeId, bid) {
391
412
  innerBid = bid;
@@ -398,7 +419,7 @@ describe('currency', function () {
398
419
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
399
420
  setConfig({ 'adServerCurrency': 'GBP' });
400
421
  fakeCurrencyFileServer.respond();
401
- var bid = { 'cpm': 1, 'currency': 'CNY' };
422
+ var bid = makeBid({ 'cpm': 1, 'currency': 'CNY' });
402
423
  var innerBid;
403
424
  addBidResponseHook(function(adCodeId, bid) {
404
425
  innerBid = bid;
@@ -411,7 +432,7 @@ describe('currency', function () {
411
432
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
412
433
  setConfig({ 'adServerCurrency': 'CNY' });
413
434
  fakeCurrencyFileServer.respond();
414
- var bid = { 'cpm': 1, 'currency': 'JPY' };
435
+ var bid = makeBid({ 'cpm': 1, 'currency': 'JPY' });
415
436
  var innerBid;
416
437
  addBidResponseHook(function(adCodeId, bid) {
417
438
  innerBid = bid;
@@ -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
+ })