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
@@ -1,6 +1,7 @@
1
1
  import {
2
- _sendAdToCreative, receiveMessage
2
+ _sendAdToCreative, getReplier, receiveMessage
3
3
  } from 'src/secureCreatives.js';
4
+ import * as secureCreatives from 'src/secureCreatives.js';
4
5
  import * as utils from 'src/utils.js';
5
6
  import {getAdUnits, getBidRequests, getBidResponses} from 'test/fixtures/fixtures.js';
6
7
  import {auctionManager} from 'src/auctionManager.js';
@@ -9,12 +10,51 @@ import * as native from 'src/native.js';
9
10
  import {fireNativeTrackers, getAllAssetsMessage} from 'src/native.js';
10
11
  import events from 'src/events.js';
11
12
  import { config as configObj } from 'src/config.js';
13
+ import 'src/prebid.js';
12
14
 
13
15
  import { expect } from 'chai';
14
16
 
15
17
  var CONSTANTS = require('src/constants.json');
16
18
 
17
19
  describe('secureCreatives', () => {
20
+ function makeEvent(ev) {
21
+ return Object.assign({origin: 'mock-origin', ports: []}, ev)
22
+ }
23
+
24
+ describe('getReplier', () => {
25
+ it('should use source.postMessage if no MessagePort is available', () => {
26
+ const ev = {
27
+ ports: [],
28
+ source: {
29
+ postMessage: sinon.spy()
30
+ },
31
+ origin: 'mock-origin'
32
+ };
33
+ getReplier(ev)('test');
34
+ sinon.assert.calledWith(ev.source.postMessage, JSON.stringify('test'));
35
+ });
36
+
37
+ it('should use MesagePort.postMessage if available', () => {
38
+ const ev = {
39
+ ports: [{
40
+ postMessage: sinon.spy()
41
+ }]
42
+ }
43
+ getReplier(ev)('test');
44
+ sinon.assert.calledWith(ev.ports[0].postMessage, JSON.stringify('test'));
45
+ });
46
+
47
+ it('should throw if origin is null and no MessagePort is available', () => {
48
+ const ev = {
49
+ origin: null,
50
+ ports: [],
51
+ postMessage: sinon.spy()
52
+ }
53
+ const reply = getReplier(ev);
54
+ expect(() => reply('test')).to.throw();
55
+ });
56
+ });
57
+
18
58
  describe('_sendAdToCreative', () => {
19
59
  beforeEach(function () {
20
60
  sinon.stub(utils, 'logError');
@@ -40,14 +80,10 @@ describe('secureCreatives', () => {
40
80
  cpm: '1.00',
41
81
  adUnitCode: 'some_dom_id'
42
82
  };
43
- const event = {
44
- source: { postMessage: sinon.stub() },
45
- origin: 'origin.sf.com'
46
- };
47
-
48
- _sendAdToCreative(mockAdObject, event);
49
- expect(JSON.parse(event.source.postMessage.args[0][0]).ad).to.equal('<script src="http://prebid.org/creative/1.00"></script>');
50
- expect(JSON.parse(event.source.postMessage.args[0][0]).adUrl).to.equal('http://creative.prebid.org/1.00');
83
+ const reply = sinon.spy();
84
+ _sendAdToCreative(mockAdObject, reply);
85
+ expect(reply.args[0][0].ad).to.equal('<script src="http://prebid.org/creative/1.00"></script>');
86
+ expect(reply.args[0][0].adUrl).to.equal('http://creative.prebid.org/1.00');
51
87
  window.googletag = oldVal;
52
88
  window.apntag = oldapntag;
53
89
  });
@@ -141,9 +177,9 @@ describe('secureCreatives', () => {
141
177
  message: 'Prebid Request'
142
178
  };
143
179
 
144
- const ev = {
145
- data: JSON.stringify(data)
146
- };
180
+ const ev = makeEvent({
181
+ data: JSON.stringify(data),
182
+ });
147
183
 
148
184
  receiveMessage(ev);
149
185
 
@@ -168,9 +204,9 @@ describe('secureCreatives', () => {
168
204
  message: 'Prebid Request'
169
205
  };
170
206
 
171
- const ev = {
207
+ const ev = makeEvent({
172
208
  data: JSON.stringify(data)
173
- };
209
+ });
174
210
 
175
211
  receiveMessage(ev);
176
212
 
@@ -209,9 +245,9 @@ describe('secureCreatives', () => {
209
245
  message: 'Prebid Request'
210
246
  };
211
247
 
212
- const ev = {
248
+ const ev = makeEvent({
213
249
  data: JSON.stringify(data)
214
- };
250
+ });
215
251
 
216
252
  receiveMessage(ev);
217
253
 
@@ -237,6 +273,38 @@ describe('secureCreatives', () => {
237
273
 
238
274
  configObj.setConfig({'auctionOptions': {}});
239
275
  });
276
+
277
+ it('should emit AD_RENDER_FAILED if requested missing adId', () => {
278
+ const ev = makeEvent({
279
+ data: JSON.stringify({
280
+ message: 'Prebid Request',
281
+ adId: 'missing'
282
+ })
283
+ });
284
+ receiveMessage(ev);
285
+ sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
286
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD,
287
+ adId: 'missing'
288
+ }));
289
+ });
290
+
291
+ it('should emit AD_RENDER_FAILED if creative can\'t be sent to rendering frame', () => {
292
+ pushBidResponseToAuction({});
293
+ const ev = makeEvent({
294
+ source: {
295
+ postMessage: sinon.stub().callsFake(() => { throw new Error(); })
296
+ },
297
+ data: JSON.stringify({
298
+ message: 'Prebid Request',
299
+ adId: bidId
300
+ })
301
+ });
302
+ receiveMessage(ev)
303
+ sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.AD_RENDER_FAILED, sinon.match({
304
+ reason: CONSTANTS.AD_RENDER_FAILED_REASON.EXCEPTION,
305
+ adId: bidId
306
+ }));
307
+ });
240
308
  });
241
309
 
242
310
  describe('Prebid Native', function() {
@@ -249,13 +317,13 @@ describe('secureCreatives', () => {
249
317
  action: 'allAssetRequest'
250
318
  };
251
319
 
252
- const ev = {
320
+ const ev = makeEvent({
253
321
  data: JSON.stringify(data),
254
322
  source: {
255
323
  postMessage: sinon.stub()
256
324
  },
257
325
  origin: 'any origin'
258
- };
326
+ });
259
327
 
260
328
  receiveMessage(ev);
261
329
 
@@ -278,13 +346,13 @@ describe('secureCreatives', () => {
278
346
  action: 'allAssetRequest'
279
347
  };
280
348
 
281
- const ev = {
349
+ const ev = makeEvent({
282
350
  data: JSON.stringify(data),
283
351
  source: {
284
352
  postMessage: sinon.stub()
285
353
  },
286
354
  origin: 'any origin'
287
- };
355
+ });
288
356
 
289
357
  receiveMessage(ev);
290
358
 
@@ -322,13 +390,13 @@ describe('secureCreatives', () => {
322
390
  action: 'allAssetRequest'
323
391
  };
324
392
 
325
- const ev = {
393
+ const ev = makeEvent({
326
394
  data: JSON.stringify(data),
327
395
  source: {
328
396
  postMessage: sinon.stub()
329
397
  },
330
398
  origin: 'any origin'
331
- };
399
+ });
332
400
 
333
401
  receiveMessage(ev);
334
402
 
@@ -366,13 +434,13 @@ describe('secureCreatives', () => {
366
434
  action: 'click',
367
435
  };
368
436
 
369
- const ev = {
437
+ const ev = makeEvent({
370
438
  data: JSON.stringify(data),
371
439
  source: {
372
440
  postMessage: sinon.stub()
373
441
  },
374
442
  origin: 'any origin'
375
- };
443
+ });
376
444
 
377
445
  receiveMessage(ev);
378
446
 
@@ -395,5 +463,56 @@ describe('secureCreatives', () => {
395
463
  expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED);
396
464
  });
397
465
  });
466
+
467
+ describe('Prebid Event', () => {
468
+ Object.entries({
469
+ 'unrendered': [false, (bid) => { delete bid.status; }],
470
+ 'rendered': [true, (bid) => { bid.status = CONSTANTS.BID_STATUS.RENDERED }]
471
+ }).forEach(([test, [shouldEmit, prepBid]]) => {
472
+ describe(`for ${test} bids`, () => {
473
+ beforeEach(() => {
474
+ prepBid(adResponse);
475
+ pushBidResponseToAuction(adResponse);
476
+ });
477
+
478
+ it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_FAILED`, () => {
479
+ const event = makeEvent({
480
+ data: JSON.stringify({
481
+ message: 'Prebid Event',
482
+ event: CONSTANTS.EVENTS.AD_RENDER_FAILED,
483
+ adId: bidId,
484
+ info: {
485
+ reason: 'Fail reason',
486
+ message: 'Fail message',
487
+ },
488
+ })
489
+ });
490
+ receiveMessage(event);
491
+ expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_FAILED, {
492
+ adId: bidId,
493
+ bid: adResponse,
494
+ reason: 'Fail reason',
495
+ message: 'Fail message'
496
+ })).to.equal(shouldEmit);
497
+ });
498
+
499
+ it(`should${shouldEmit ? ' ' : ' not '}emit AD_RENDER_SUCCEEDED`, () => {
500
+ const event = makeEvent({
501
+ data: JSON.stringify({
502
+ message: 'Prebid Event',
503
+ event: CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED,
504
+ adId: bidId,
505
+ })
506
+ });
507
+ receiveMessage(event);
508
+ expect(stubEmit.calledWith(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, {
509
+ adId: bidId,
510
+ bid: adResponse,
511
+ doc: null
512
+ })).to.equal(shouldEmit);
513
+ });
514
+ });
515
+ });
516
+ });
398
517
  });
399
518
  });
@@ -2,6 +2,8 @@ import chai from 'chai';
2
2
  import { getCacheUrl, store } from 'src/videoCache.js';
3
3
  import { config } from 'src/config.js';
4
4
  import { server } from 'test/mocks/xhr.js';
5
+ import {auctionManager} from '../../src/auctionManager.js';
6
+ import {AuctionIndex} from '../../src/auctionIndex.js';
5
7
 
6
8
  const should = chai.should();
7
9
 
@@ -32,23 +34,6 @@ function getMockBid(bidder, auctionId, bidderRequestId) {
32
34
  };
33
35
  }
34
36
 
35
- function getMockBidRequest(bidder = 'appnexus', auctionId = '173afb6d132ba3', bidderRequestId = '3d1063078dfcc8') {
36
- return {
37
- 'bidderCode': bidder,
38
- 'auctionId': auctionId,
39
- 'bidderRequestId': bidderRequestId,
40
- 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5',
41
- 'bids': [getMockBid(bidder, auctionId, bidderRequestId)],
42
- 'auctionStart': 1510852447530,
43
- 'timeout': 5000,
44
- 'src': 's2s',
45
- 'doneCbCallCount': 0,
46
- 'refererInfo': {
47
- 'referer': 'http://mytestpage.com'
48
- }
49
- }
50
- }
51
-
52
37
  describe('The video cache', function () {
53
38
  function assertError(callbackSpy) {
54
39
  callbackSpy.calledOnce.should.equal(true);
@@ -240,7 +225,7 @@ describe('The video cache', function () {
240
225
  JSON.parse(request.requestBody).should.deep.equal(payload);
241
226
  });
242
227
 
243
- it('should include additional params in request payload should config.cache.vasttrack be true and bidderRequest argument was defined', () => {
228
+ it('should include additional params in request payload should config.cache.vasttrack be true - with timestamp', () => {
244
229
  config.setConfig({
245
230
  cache: {
246
231
  url: 'https://prebid.adnxs.com/pbc/v1/cache',
@@ -269,7 +254,21 @@ describe('The video cache', function () {
269
254
  auctionId: '1234-56789-abcde'
270
255
  }];
271
256
 
272
- store(bids, function () { }, getMockBidRequest());
257
+ const stub = sinon.stub(auctionManager, 'index');
258
+ stub.get(() => new AuctionIndex(() => [{
259
+ getAuctionId() {
260
+ return '1234-56789-abcde';
261
+ },
262
+ getAuctionStart() {
263
+ return 1510852447530;
264
+ }
265
+ }]))
266
+ try {
267
+ store(bids, function () { });
268
+ } finally {
269
+ stub.restore();
270
+ }
271
+
273
272
  const request = server.requests[0];
274
273
  request.method.should.equal('POST');
275
274
  request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache');
@@ -1,113 +1,103 @@
1
1
  import { isValidVideoBid } from 'src/video.js';
2
+ import {hook} from '../../src/hook.js';
3
+ import {stubAuctionIndex} from '../helpers/indexStub.js';
2
4
 
3
5
  describe('video.js', function () {
6
+ before(() => {
7
+ hook.ready();
8
+ });
9
+
4
10
  it('validates valid instream bids', function () {
5
11
  const bid = {
6
12
  adId: '456xyz',
7
13
  vastUrl: 'http://www.example.com/vastUrl',
8
- requestId: '123abc'
14
+ transactionId: 'au'
9
15
  };
10
- const bidRequests = [{
11
- bids: [{
12
- bidId: '123abc',
13
- bidder: 'appnexus',
14
- mediaTypes: {
15
- video: { context: 'instream' }
16
- }
17
- }]
16
+ const adUnits = [{
17
+ transactionId: 'au',
18
+ mediaTypes: {
19
+ video: {context: 'instream'}
20
+ }
18
21
  }];
19
- const valid = isValidVideoBid(bid, bidRequests);
22
+ const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
20
23
  expect(valid).to.equal(true);
21
24
  });
22
25
 
23
26
  it('catches invalid instream bids', function () {
24
27
  const bid = {
25
- requestId: '123abc'
28
+ transactionId: 'au'
26
29
  };
27
- const bidRequests = [{
28
- bids: [{
29
- bidId: '123abc',
30
- bidder: 'appnexus',
31
- mediaTypes: {
32
- video: { context: 'instream' }
33
- }
34
- }]
30
+ const adUnits = [{
31
+ transactionId: 'au',
32
+ mediaTypes: {
33
+ video: {context: 'instream'}
34
+ }
35
35
  }];
36
- const valid = isValidVideoBid(bid, bidRequests);
36
+ const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
37
37
  expect(valid).to.equal(false);
38
38
  });
39
39
 
40
40
  it('catches invalid bids when prebid-cache is disabled', function () {
41
- const bidRequests = [{
42
- bids: [{
43
- bidder: 'vastOnlyVideoBidder',
44
- mediaTypes: { video: {} },
45
- }]
41
+ const adUnits = [{
42
+ transactionId: 'au',
43
+ bidder: 'vastOnlyVideoBidder',
44
+ mediaTypes: {video: {}},
46
45
  }];
47
46
 
48
- const valid = isValidVideoBid({ vastXml: '<xml>vast</xml>' }, bidRequests);
47
+ const valid = isValidVideoBid({ transactionId: 'au', vastXml: '<xml>vast</xml>' }, {index: stubAuctionIndex({adUnits})});
49
48
 
50
49
  expect(valid).to.equal(false);
51
50
  });
52
51
 
53
52
  it('validates valid outstream bids', function () {
54
53
  const bid = {
55
- requestId: '123abc',
54
+ transactionId: 'au',
56
55
  renderer: {
57
56
  url: 'render.url',
58
57
  render: () => true,
59
58
  }
60
59
  };
61
- const bidRequests = [{
62
- bids: [{
63
- bidId: '123abc',
64
- bidder: 'appnexus',
65
- mediaTypes: {
66
- video: { context: 'outstream' }
67
- }
68
- }]
60
+ const adUnits = [{
61
+ transactionId: 'au',
62
+ mediaTypes: {
63
+ video: {context: 'outstream'}
64
+ }
69
65
  }];
70
- const valid = isValidVideoBid(bid, bidRequests);
66
+ const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
71
67
  expect(valid).to.equal(true);
72
68
  });
73
69
 
74
70
  it('validates valid outstream bids with a publisher defined renderer', function () {
75
71
  const bid = {
76
- requestId: '123abc',
72
+ transactionId: 'au',
77
73
  };
78
- const bidRequests = [{
79
- bids: [{
80
- bidId: '123abc',
81
- bidder: 'appnexus',
82
- mediaTypes: {
83
- video: {
84
- context: 'outstream',
85
- renderer: {
86
- url: 'render.url',
87
- render: () => true,
88
- }
89
- }
74
+ const adUnits = [{
75
+ transactionId: 'au',
76
+ mediaTypes: {
77
+ video: {
78
+ context: 'outstream',
90
79
  }
91
- }]
80
+ },
81
+ renderer: {
82
+ url: 'render.url',
83
+ render: () => true,
84
+ }
92
85
  }];
93
- const valid = isValidVideoBid(bid, bidRequests);
86
+ const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
94
87
  expect(valid).to.equal(true);
95
88
  });
96
89
 
97
90
  it('catches invalid outstream bids', function () {
98
91
  const bid = {
99
- requestId: '123abc'
92
+ transactionId: 'au',
100
93
  };
101
- const bidRequests = [{
102
- bids: [{
103
- bidId: '123abc',
104
- bidder: 'appnexus',
105
- mediaTypes: {
106
- video: { context: 'outstream' }
107
- }
108
- }]
94
+ const adUnits = [{
95
+ transactionId: 'au',
96
+ mediaTypes: {
97
+ video: {context: 'outstream'}
98
+ }
109
99
  }];
110
- const valid = isValidVideoBid(bid, bidRequests);
100
+ const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
111
101
  expect(valid).to.equal(false);
112
102
  });
113
103
  });