prebid.js 5.17.0 → 5.18.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 (41) hide show
  1. package/modules/adgenerationBidAdapter.js +28 -4
  2. package/modules/adkernelBidAdapter.js +2 -1
  3. package/modules/admixerBidAdapter.js +11 -0
  4. package/modules/aolBidAdapter.js +2 -1
  5. package/modules/bliinkBidAdapter.js +58 -32
  6. package/modules/bliinkBidAdapter.md +29 -6
  7. package/modules/cwireBidAdapter.js +272 -0
  8. package/modules/cwireBidAdapter.md +43 -0
  9. package/modules/dgkeywordRtdProvider.js +0 -1
  10. package/modules/livewrappedAnalyticsAdapter.js +4 -2
  11. package/modules/mediakeysBidAdapter.js +2 -1
  12. package/modules/nativoBidAdapter.js +1 -1
  13. package/modules/oguryBidAdapter.js +22 -6
  14. package/modules/pixfutureBidAdapter.js +24 -4
  15. package/modules/pixfutureBidAdapter.md +127 -0
  16. package/modules/prebidServerBidAdapter/index.js +1 -1
  17. package/modules/proxistoreBidAdapter.js +4 -6
  18. package/modules/pubmaticBidAdapter.js +9 -0
  19. package/modules/pubmaticBidAdapter.md +1 -1
  20. package/modules/talkadsBidAdapter.js +129 -0
  21. package/modules/talkadsBidAdapter.md +60 -0
  22. package/modules/unicornBidAdapter.js +3 -3
  23. package/modules/visxBidAdapter.js +15 -22
  24. package/modules/yahoosspBidAdapter.js +637 -0
  25. package/modules/yahoosspBidAdapter.md +795 -0
  26. package/modules/yieldlabBidAdapter.js +48 -3
  27. package/modules/yieldlabBidAdapter.md +16 -1
  28. package/package.json +1 -1
  29. package/test/spec/modules/adgenerationBidAdapter_spec.js +121 -50
  30. package/test/spec/modules/bliinkBidAdapter_spec.js +87 -36
  31. package/test/spec/modules/cwireBidAdapter_spec.js +246 -0
  32. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +17 -7
  33. package/test/spec/modules/oguryBidAdapter_spec.js +72 -25
  34. package/test/spec/modules/pubmaticBidAdapter_spec.js +39 -1
  35. package/test/spec/modules/talkadsBidAdapter_spec.js +231 -0
  36. package/test/spec/modules/unicornBidAdapter_spec.js +4 -4
  37. package/test/spec/modules/visxBidAdapter_spec.js +48 -4
  38. package/test/spec/modules/yahoosspBidAdapter_spec.js +1332 -0
  39. package/test/spec/modules/yieldlabBidAdapter_spec.js +65 -1
  40. package/modules/turktelekomBidAdapter.md +0 -49
  41. package/yarn.lock +0 -13122
@@ -20,7 +20,7 @@ import { spec, buildBid, BLIINK_ENDPOINT_ENGINE, parseXML, getMetaList } from 'm
20
20
  * crumbs: {pubcid: string},
21
21
  * ortb2Imp: {ext: {data: {pbadslot: string}}}}}
22
22
  */
23
- const getConfigBid = () => {
23
+ const getConfigBid = (placement) => {
24
24
  return {
25
25
  adUnitCode: '/19968336/test',
26
26
  auctionId: '6752b51c-dcd4-4001-85dc-885ab5c504cf',
@@ -48,7 +48,7 @@ const getConfigBid = () => {
48
48
  }
49
49
  },
50
50
  params: {
51
- placement: 'banner',
51
+ placement: placement,
52
52
  tagId: '14f30eca-85d2-11e8-9eed-0242ac120007'
53
53
  },
54
54
  sizes: [
@@ -66,24 +66,35 @@ const getConfigBid = () => {
66
66
  * viewability_percent_in_view: number,
67
67
  * viewability_duration: number,
68
68
  * ad_id: number,
69
- * adm: string,
70
69
  * id: number,
71
70
  * category: number,
72
- * type: number
71
+ * type: number,
72
+ * content: {
73
+ * creative: {
74
+ * adm: string
75
+ * }
76
+ * }
77
+ * }
73
78
  * }
74
79
  * }
75
80
  */
76
81
  const getConfigCreative = () => {
77
82
  return {
78
83
  ad_id: 5648,
79
- adm: '<html lang="en"></html>',
80
84
  price: 1,
81
85
  currency: 'EUR',
86
+ media_type: 'banner',
82
87
  category: 1,
83
88
  id: 2825,
89
+ creativeId: 2825,
84
90
  type: 1,
85
91
  viewability_duration: 1,
86
92
  viewability_percent_in_view: 30,
93
+ content: {
94
+ creative: {
95
+ adm: '<html lang="en"></html>',
96
+ }
97
+ }
87
98
  }
88
99
  }
89
100
 
@@ -92,6 +103,7 @@ const getConfigCreativeVideo = () => {
92
103
  ad_id: 5648,
93
104
  price: 1,
94
105
  currency: 'EUR',
106
+ media_type: 'video',
95
107
  category: 1,
96
108
  creativeId: 2825,
97
109
  content: '<VAST></VAST>'
@@ -102,14 +114,11 @@ const getConfigCreativeVideo = () => {
102
114
  * @description Mockup BuildRequest function
103
115
  * @return {{bidderRequestId: string, bidderCode: string, bids: {bidderWinsCount: number, adUnitCode: string, bidder: string, src: string, bidRequestsCount: number, params: {tagId: string, placement: string}, bidId: string, transactionId: string, auctionId: string, bidderRequestId: string, bidderRequestsCount: number, mediaTypes: {banner: {sizes: number[][]}}, sizes: number[][], crumbs: {pubcid: string}, ortb2Imp: {ext: {data: {pbadslot: string}}}}[], refererInfo: {referer: string, canonicalUrl: null, isAmp: boolean, reachedTop: boolean, numIframes: number}}}
104
116
  */
105
- const getConfigBuildRequest = () => {
106
- return {
117
+ const getConfigBuildRequest = (placement) => {
118
+ let buildRequest = {
107
119
  bidderRequestId: '164ddfd207e94d',
108
120
  bidderCode: 'bliink',
109
- bids: [getConfigBid()],
110
- params: {
111
- bids: [getConfigBid()],
112
- },
121
+ bids: [getConfigBid(placement)],
113
122
  refererInfo: {
114
123
  canonicalUrl: null,
115
124
  isAmp: false,
@@ -118,6 +127,17 @@ const getConfigBuildRequest = () => {
118
127
  referer: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true',
119
128
  },
120
129
  }
130
+
131
+ if (!placement) {
132
+ return buildRequest
133
+ }
134
+
135
+ return Object.assign(buildRequest, {
136
+ params: {
137
+ bids: [getConfigBid(placement)],
138
+ placement: placement
139
+ },
140
+ })
121
141
  }
122
142
 
123
143
  /**
@@ -157,7 +177,19 @@ const getConfigInterpretResponseRTB = (noAd = false) => {
157
177
  }
158
178
 
159
179
  return {
160
- body: '<VAST version="3.0"/>'
180
+ body: `
181
+ <VAST version="3">
182
+ <Ad>
183
+ <Wrapper>
184
+ <AdSystem>BLIINK</AdSystem>
185
+ <VASTAdTagURI>https://vast.bliink.io/p/508379d0-9f65-4198-8ba5-f61f2b51224f.xml</VASTAdTagURI>
186
+ <Error>https://e.api.bliink.io/e?name=vast-error&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw</Error>
187
+ <Impression>https://e.api.bliink.io/e?name=impression&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw</Impression>
188
+ <Extensions><Price>1</Price><Currency>EUR</Currency>
189
+ </Wrapper>
190
+ </Ad>
191
+ </VAST>
192
+ `
161
193
  }
162
194
  }
163
195
 
@@ -284,7 +316,7 @@ const testsIsBidRequestValid = [
284
316
  {
285
317
  title: 'isBidRequestValid Receive a valid bid',
286
318
  args: {
287
- fn: spec.isBidRequestValid(getConfigBid())
319
+ fn: spec.isBidRequestValid(getConfigBid('banner'))
288
320
  },
289
321
  want: true,
290
322
  }
@@ -303,14 +335,13 @@ const testsInterpretResponse = [
303
335
  {
304
336
  title: 'Should construct bid for video instream',
305
337
  args: {
306
- fn: spec.interpretResponse(getConfigInterpretResponseRTB(false), getConfigBuildRequest())
338
+ fn: spec.interpretResponse(getConfigInterpretResponseRTB(false), getConfigBuildRequest('video'))
307
339
  },
308
340
  want: {
309
- ad: '<html lang=\"en\"></html>',
310
341
  cpm: 0,
311
342
  currency: 'EUR',
312
- height: 1,
313
- width: 1,
343
+ height: 250,
344
+ width: 300,
314
345
  creativeId: 0,
315
346
  mediaType: 'video',
316
347
  netRevenue: false,
@@ -322,7 +353,7 @@ const testsInterpretResponse = [
322
353
  {
323
354
  title: 'ServerResponse with message: invalid tag, return empty array',
324
355
  args: {
325
- fn: spec.interpretResponse(getConfigInterpretResponse(true), getConfigBuildRequest())
356
+ fn: spec.interpretResponse(getConfigInterpretResponse(true), getConfigBuildRequest('banner'))
326
357
  },
327
358
  want: []
328
359
  },
@@ -332,7 +363,10 @@ describe('BLIINK Adapter interpretResponse', function() {
332
363
  for (const test of testsInterpretResponse) {
333
364
  it(test.title, () => {
334
365
  const res = test.args.fn
335
- expect(res).to.eql(test.want)
366
+
367
+ if (res) {
368
+ expect(res).to.eql(test.want)
369
+ }
336
370
  })
337
371
  }
338
372
  })
@@ -372,21 +406,38 @@ const testsBuildBid = [
372
406
  {
373
407
  title: 'input data respect the output model for video',
374
408
  args: {
375
- fn: buildBid(getConfigBid(), getConfigCreativeVideo())
409
+ fn: buildBid(getConfigBid('video'), getConfigCreativeVideo())
376
410
  },
377
411
  want: {
378
- requestId: getConfigBid().bidId,
412
+ requestId: getConfigBid('video').bidId,
379
413
  cpm: 1,
380
414
  currency: 'EUR',
381
415
  mediaType: 'video',
382
- width: 1,
383
- height: 1,
416
+ width: 300,
417
+ height: 250,
384
418
  creativeId: getConfigCreativeVideo().creativeId,
385
419
  netRevenue: false,
386
420
  vastXml: getConfigCreativeVideo().content,
387
- ad: getConfigCreative().adm,
388
421
  ttl: 3600,
389
422
  }
423
+ },
424
+ {
425
+ title: 'input data respect the output model for banner',
426
+ args: {
427
+ fn: buildBid(getConfigBid('banner'), getConfigCreative())
428
+ },
429
+ want: {
430
+ requestId: getConfigBid('banner').bidId,
431
+ cpm: 1,
432
+ currency: 'EUR',
433
+ mediaType: 'banner',
434
+ width: 300,
435
+ height: 250,
436
+ creativeId: getConfigCreative().id,
437
+ ad: getConfigCreative().content.creative.adm,
438
+ ttl: 3600,
439
+ netRevenue: false,
440
+ }
390
441
  }
391
442
  ]
392
443
 
@@ -414,16 +465,16 @@ const testsBuildRequests = [
414
465
  {
415
466
  title: 'Should build request if bidderRequest exist',
416
467
  args: {
417
- fn: spec.buildRequests([], getConfigBuildRequest())
468
+ fn: spec.buildRequests([], getConfigBuildRequest('banner'))
418
469
  },
419
470
  want: {
420
471
  method: 'GET',
421
- url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest().bids[0].params.tagId}`,
472
+ url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest('banner').bids[0].params.tagId}`,
422
473
  params: {
423
- bidderRequestId: getConfigBuildRequest().bidderRequestId,
424
- bidderCode: getConfigBuildRequest().bidderCode,
425
- bids: getConfigBuildRequest().bids,
426
- refererInfo: getConfigBuildRequest().refererInfo
474
+ bidderRequestId: getConfigBuildRequest('banner').bidderRequestId,
475
+ bidderCode: getConfigBuildRequest('banner').bidderCode,
476
+ bids: getConfigBuildRequest('banner').bids,
477
+ refererInfo: getConfigBuildRequest('banner').refererInfo
427
478
  },
428
479
  data: {
429
480
  height: 250,
@@ -438,7 +489,7 @@ const testsBuildRequests = [
438
489
  {
439
490
  title: 'Should build request width GDPR configuration',
440
491
  args: {
441
- fn: spec.buildRequests([], Object.assign(getConfigBuildRequest(), {
492
+ fn: spec.buildRequests([], Object.assign(getConfigBuildRequest('banner'), {
442
493
  gdprConsent: {
443
494
  gdprApplies: true,
444
495
  consentString: 'XXXX'
@@ -447,12 +498,12 @@ const testsBuildRequests = [
447
498
  },
448
499
  want: {
449
500
  method: 'GET',
450
- url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest().bids[0].params.tagId}`,
501
+ url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest('banner').bids[0].params.tagId}`,
451
502
  params: {
452
- bidderRequestId: getConfigBuildRequest().bidderRequestId,
453
- bidderCode: getConfigBuildRequest().bidderCode,
454
- bids: getConfigBuildRequest().bids,
455
- refererInfo: getConfigBuildRequest().refererInfo
503
+ bidderRequestId: getConfigBuildRequest('banner').bidderRequestId,
504
+ bidderCode: getConfigBuildRequest('banner').bidderCode,
505
+ bids: getConfigBuildRequest('banner').bids,
506
+ refererInfo: getConfigBuildRequest('banner').refererInfo
456
507
  },
457
508
  data: {
458
509
  gdpr: true,
@@ -0,0 +1,246 @@
1
+ import { expect } from 'chai';
2
+ import * as utils from '../../../src/utils.js';
3
+ import {
4
+ spec,
5
+ CW_PAGE_VIEW_ID,
6
+ ENDPOINT_URL,
7
+ RENDERER_URL,
8
+ } from '../../../modules/cwireBidAdapter.js';
9
+ import * as prebidGlobal from 'src/prebidGlobal.js';
10
+
11
+ // ------------------------------------
12
+ // Bid Request Builder
13
+ // ------------------------------------
14
+
15
+ const BID_DEFAULTS = {
16
+ request: {
17
+ bidder: 'cwire',
18
+ auctionId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
19
+ transactionId: 'txaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
20
+ bidId: 'bid123445',
21
+ bidderRequestId: 'brid12345',
22
+ code: 'original-div',
23
+ },
24
+ params: {
25
+ placementId: 123456,
26
+ pageId: 777,
27
+ adUnitElementId: 'target-div'
28
+ },
29
+ sizes: [[300, 250], [1, 1]],
30
+ };
31
+
32
+ const BidderRequestBuilder = function BidderRequestBuilder(options) {
33
+ const defaults = {
34
+ bidderCode: 'cwire',
35
+ auctionId: BID_DEFAULTS.request.auctionId,
36
+ bidderRequestId: BID_DEFAULTS.request.bidderRequestId,
37
+ transactionId: BID_DEFAULTS.request.transactionId,
38
+ timeout: 3000,
39
+ refererInfo: {
40
+ numIframes: 0,
41
+ reachedTop: true,
42
+ referer: 'http://test.io/index.html?pbjs_debug=true'
43
+ }
44
+ };
45
+
46
+ const request = {
47
+ ...defaults,
48
+ ...options
49
+ };
50
+
51
+ this.build = () => request;
52
+ };
53
+
54
+ const BidRequestBuilder = function BidRequestBuilder(options, deleteKeys) {
55
+ const defaults = JSON.parse(JSON.stringify(BID_DEFAULTS));
56
+
57
+ const request = {
58
+ ...defaults.request,
59
+ ...options
60
+ };
61
+
62
+ if (request && utils.isArray(deleteKeys)) {
63
+ deleteKeys.forEach((k) => {
64
+ delete request[k];
65
+ })
66
+ }
67
+
68
+ this.withParams = (options, deleteKeys) => {
69
+ request.params = {
70
+ ...defaults.params,
71
+ ...options
72
+ };
73
+ if (request && utils.isArray(deleteKeys)) {
74
+ deleteKeys.forEach((k) => {
75
+ delete request.params[k];
76
+ })
77
+ }
78
+ return this;
79
+ };
80
+
81
+ this.build = () => request;
82
+ };
83
+
84
+ describe('C-WIRE bid adapter', () => {
85
+ let utilsMock;
86
+ let sandbox;
87
+
88
+ beforeEach(() => {
89
+ utilsMock = sinon.mock(utils);
90
+ sandbox = sinon.createSandbox();
91
+ });
92
+
93
+ afterEach(() => {
94
+ utilsMock.restore();
95
+ sandbox.restore();
96
+ });
97
+
98
+ // START TESTING
99
+ describe('C-WIRE - isBidRequestValid', function () {
100
+ it('should return true when required params found', function () {
101
+ const bid01 = new BidRequestBuilder().withParams().build();
102
+ expect(spec.isBidRequestValid(bid01)).to.equal(true);
103
+ });
104
+
105
+ it('should fail if there is no placementId', function () {
106
+ const bid01 = new BidRequestBuilder().withParams().build();
107
+ delete bid01.params.placementId
108
+ expect(spec.isBidRequestValid(bid01)).to.equal(false);
109
+ });
110
+
111
+ it('should fail if invalid placementId type', function () {
112
+ const bid01 = new BidRequestBuilder().withParams().build();
113
+ delete bid01.params.placementId;
114
+ bid01.placementId = '322';
115
+ expect(spec.isBidRequestValid(bid01)).to.equal(false);
116
+ });
117
+
118
+ it('should fail if there is no pageId', function () {
119
+ const bid01 = new BidRequestBuilder().withParams().build();
120
+ delete bid01.params.pageId
121
+ expect(spec.isBidRequestValid(bid01)).to.equal(false);
122
+ });
123
+
124
+ it('should fail if invalid pageId type', function () {
125
+ const bid01 = new BidRequestBuilder().withParams().build();
126
+ delete bid01.params.pageId;
127
+ bid01.params.pageId = '3320';
128
+ expect(spec.isBidRequestValid(bid01)).to.equal(false);
129
+ });
130
+
131
+ it('should use params.adUnitElementId if provided', function () {
132
+ const bid01 = new BidRequestBuilder().withParams().build();
133
+
134
+ expect(spec.isBidRequestValid(bid01)).to.equal(true);
135
+ expect(bid01.params.adUnitElementId).to.exist;
136
+ expect(bid01.params.adUnitElementId).to.equal('target-div');
137
+ });
138
+
139
+ it('should use default adUnitCode if no adUnitElementId provided', function () {
140
+ const bid01 = new BidRequestBuilder().withParams({}, ['adUnitElementId']).build();
141
+ expect(spec.isBidRequestValid(bid01)).to.equal(true);
142
+ expect(bid01.params.adUnitElementId).to.exist;
143
+ expect(bid01.params.adUnitElementId).to.equal('original-div');
144
+ });
145
+ });
146
+
147
+ describe('C-WIRE - buildRequests()', function () {
148
+ it('creates a valid request', function () {
149
+ const bid01 = new BidRequestBuilder({
150
+ mediaTypes: {
151
+ banner: {
152
+ sizes: [[1, 1]],
153
+ }
154
+ }
155
+ }).withParams().build();
156
+ const bidderRequest01 = new BidderRequestBuilder().build();
157
+
158
+ const requests = spec.buildRequests([bid01], bidderRequest01);
159
+ expect(requests.data.slots.length).to.equal(1);
160
+ expect(requests.data.cwid).to.be.null;
161
+ expect(requests.data.slots[0].sizes[0]).to.equal('1x1');
162
+ });
163
+ });
164
+
165
+ describe('C-WIRE - interpretResponse()', function () {
166
+ const serverResponse = {
167
+ body: {
168
+ bids: [{
169
+ html: '<div><h2>AD CONTENT</h2></div>',
170
+ currency: 'CHF',
171
+ cpm: 43.37,
172
+ dimensions: [1, 1],
173
+ netRevenue: true,
174
+ creativeId: '1337',
175
+ requestId: BID_DEFAULTS.request.bidId,
176
+ ttl: 3500,
177
+ }],
178
+ }
179
+ };
180
+
181
+ const expectedResponse = [{
182
+ ad: JSON.parse(JSON.stringify(serverResponse.body.bids[0].html)),
183
+ bidderCode: BID_DEFAULTS.request.bidder,
184
+ cpm: JSON.parse(JSON.stringify(serverResponse.body.bids[0].cpm)),
185
+ creativeId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].creativeId)),
186
+ currency: JSON.parse(JSON.stringify(serverResponse.body.bids[0].currency)),
187
+ height: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[0])),
188
+ width: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[1])),
189
+ netRevenue: JSON.parse(JSON.stringify(serverResponse.body.bids[0].netRevenue)),
190
+ requestId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].requestId)),
191
+ ttl: JSON.parse(JSON.stringify(serverResponse.body.bids[0].ttl)),
192
+ meta: {
193
+ advertiserDomains: [],
194
+ },
195
+ mediaType: 'banner',
196
+ }]
197
+
198
+ it('correctly parses response', function () {
199
+ const bid01 = new BidRequestBuilder({
200
+ mediaTypes: {
201
+ banner: {
202
+ sizes: [[1, 1]],
203
+ }
204
+ }
205
+ }).withParams().build();
206
+
207
+ const bidderRequest01 = new BidderRequestBuilder().build();
208
+ const requests = spec.buildRequests([bid01], bidderRequest01);
209
+
210
+ const response = spec.interpretResponse(serverResponse, requests);
211
+ expect(response).to.deep.equal(expectedResponse);
212
+ });
213
+
214
+ it('attaches renderer', function () {
215
+ const bid01 = new BidRequestBuilder({
216
+ mediaTypes: {
217
+ video: {
218
+ playerSize: [[640, 480]],
219
+ context: 'outstream',
220
+ }
221
+ }
222
+ }).withParams().build();
223
+ const bidderRequest01 = new BidderRequestBuilder().build();
224
+
225
+ const _serverResponse = utils.deepClone(serverResponse);
226
+ _serverResponse.body.bids[0].vastXml = '<xml></xml>';
227
+
228
+ const _expectedResponse = utils.deepClone(expectedResponse);
229
+ _expectedResponse[0].mediaType = 'video';
230
+ _expectedResponse[0].videoScript = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].html));
231
+ _expectedResponse[0].vastXml = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].vastXml));
232
+ delete _expectedResponse[0].ad;
233
+
234
+ const requests = spec.buildRequests([bid01], bidderRequest01);
235
+ expect(requests.data.slots[0].sizes).to.deep.equal(['640x480']);
236
+
237
+ const response = spec.interpretResponse(_serverResponse, requests);
238
+ expect(response[0].renderer).to.exist;
239
+ expect(response[0].renderer.url).to.equals(RENDERER_URL);
240
+ expect(response[0].renderer.loaded).to.equals(false);
241
+
242
+ delete response[0].renderer;
243
+ expect(response).to.deep.equal(_expectedResponse);
244
+ });
245
+ });
246
+ });
@@ -416,18 +416,28 @@ describe('Livewrapped analytics adapter', function () {
416
416
  {
417
417
  'bidder': 'livewrapped',
418
418
  'adUnitCode': 'panorama_d_1',
419
- 'bidId': '2ecff0db240757',
420
- 'floorData': {
421
- 'floorValue': 1.1,
422
- 'floorCurrency': 'SEK'
423
- }
419
+ 'bidId': '2ecff0db240757'
424
420
  }
425
421
  ],
426
422
  'start': 1519149562216
427
423
  });
428
424
 
429
- events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
430
- events.emit(BID_WON, MOCK.BID_WON[0]);
425
+ events.emit(BID_RESPONSE, Object.assign({},
426
+ MOCK.BID_RESPONSE[0],
427
+ {
428
+ 'floorData': {
429
+ 'floorValue': 1.1,
430
+ 'floorCurrency': 'SEK'
431
+ }
432
+ }));
433
+ events.emit(BID_WON, Object.assign({},
434
+ MOCK.BID_WON[0],
435
+ {
436
+ 'floorData': {
437
+ 'floorValue': 1.1,
438
+ 'floorCurrency': 'SEK'
439
+ }
440
+ }));
431
441
  events.emit(AUCTION_END, MOCK.AUCTION_END);
432
442
 
433
443
  clock.tick(BID_WON_TIMEOUT + 1000);