prebid.js 7.23.0 → 7.24.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 (159) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/adagioBidAdapter.js +1 -1
  3. package/dist/adbookpspBidAdapter.js +1 -1
  4. package/dist/adgenerationBidAdapter.js +1 -1
  5. package/dist/admaticBidAdapter.js +1 -0
  6. package/dist/adrelevantisBidAdapter.js +1 -1
  7. package/dist/adtrgtmeBidAdapter.js +1 -1
  8. package/dist/adxcgBidAdapter.js +1 -1
  9. package/dist/adyoulikeBidAdapter.js +1 -1
  10. package/dist/ajaBidAdapter.js +1 -1
  11. package/dist/amxBidAdapter.js +1 -1
  12. package/dist/amxIdSystem.js +1 -1
  13. package/dist/appierAnalyticsAdapter.js +1 -1
  14. package/dist/appnexusBidAdapter.js +1 -1
  15. package/dist/asoBidAdapter.js +1 -1
  16. package/dist/audiencerunBidAdapter.js +1 -1
  17. package/dist/axonixBidAdapter.js +1 -1
  18. package/dist/bidglassBidAdapter.js +1 -1
  19. package/dist/big-richmediaBidAdapter.js +1 -1
  20. package/dist/bluebillywigBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/carodaBidAdapter.js +1 -1
  24. package/dist/chtnwBidAdapter.js +1 -1
  25. package/dist/concertBidAdapter.js +1 -1
  26. package/dist/connectIdSystem.js +1 -1
  27. package/dist/connectadBidAdapter.js +1 -1
  28. package/dist/consumableBidAdapter.js +1 -1
  29. package/dist/conversantBidAdapter.js +1 -1
  30. package/dist/craftBidAdapter.js +1 -1
  31. package/dist/criteoBidAdapter.js +1 -1
  32. package/dist/dspxBidAdapter.js +1 -1
  33. package/dist/eplanningBidAdapter.js +1 -1
  34. package/dist/finativeBidAdapter.js +1 -1
  35. package/dist/glimpseBidAdapter.js +1 -1
  36. package/dist/gmosspBidAdapter.js +1 -1
  37. package/dist/goldbachBidAdapter.js +1 -1
  38. package/dist/gridBidAdapter.js +1 -1
  39. package/dist/gridNMBidAdapter.js +1 -1
  40. package/dist/growthCodeIdSystem.js +1 -1
  41. package/dist/gumgumBidAdapter.js +1 -1
  42. package/dist/h12mediaBidAdapter.js +1 -1
  43. package/dist/id5IdSystem.js +1 -1
  44. package/dist/impactifyBidAdapter.js +1 -1
  45. package/dist/improvedigitalBidAdapter.js +1 -1
  46. package/dist/inmarBidAdapter.js +1 -1
  47. package/dist/insticatorBidAdapter.js +1 -1
  48. package/dist/ixBidAdapter.js +1 -1
  49. package/dist/jixieBidAdapter.js +1 -1
  50. package/dist/justpremiumBidAdapter.js +1 -1
  51. package/dist/konduitAnalyticsAdapter.js +1 -1
  52. package/dist/kueezBidAdapter.js +1 -1
  53. package/dist/kueezRtbBidAdapter.js +1 -0
  54. package/dist/lassoBidAdapter.js +1 -1
  55. package/dist/lifestreetBidAdapter.js +1 -1
  56. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  57. package/dist/logicadBidAdapter.js +1 -1
  58. package/dist/loglyliftBidAdapter.js +1 -1
  59. package/dist/magniteAnalyticsAdapter.js +1 -1
  60. package/dist/malltvAnalyticsAdapter.js +1 -1
  61. package/dist/marsmediaBidAdapter.js +1 -1
  62. package/dist/mediafuseBidAdapter.js +1 -1
  63. package/dist/mediakeysBidAdapter.js +1 -1
  64. package/dist/mediasquareBidAdapter.js +1 -1
  65. package/dist/mgidBidAdapter.js +1 -1
  66. package/dist/mgidRtdProvider.js +1 -0
  67. package/dist/minutemediaBidAdapter.js +1 -1
  68. package/dist/not-for-prod/prebid.js +122 -119
  69. package/dist/oguryBidAdapter.js +1 -1
  70. package/dist/onetagBidAdapter.js +1 -1
  71. package/dist/ooloAnalyticsAdapter.js +1 -1
  72. package/dist/outbrainBidAdapter.js +1 -1
  73. package/dist/parrableIdSystem.js +1 -1
  74. package/dist/pbsExtensions.js +1 -1
  75. package/dist/permutiveRtdProvider.js +1 -1
  76. package/dist/pixfutureBidAdapter.js +1 -1
  77. package/dist/prebid-core.js +1 -1
  78. package/dist/publinkIdSystem.js +1 -1
  79. package/dist/pubmaticBidAdapter.js +1 -1
  80. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  81. package/dist/pxyzBidAdapter.js +1 -1
  82. package/dist/quantcastBidAdapter.js +1 -1
  83. package/dist/readpeakBidAdapter.js +1 -1
  84. package/dist/relaidoBidAdapter.js +1 -1
  85. package/dist/rhythmoneBidAdapter.js +1 -1
  86. package/dist/riseBidAdapter.js +1 -1
  87. package/dist/rubiconAnalyticsAdapter.js +1 -1
  88. package/dist/rubiconBidAdapter.js +1 -1
  89. package/dist/seedingAllianceBidAdapter.js +1 -1
  90. package/dist/seedtagBidAdapter.js +1 -1
  91. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  92. package/dist/sharethroughBidAdapter.js +1 -1
  93. package/dist/shinezBidAdapter.js +1 -1
  94. package/dist/smaatoBidAdapter.js +1 -1
  95. package/dist/smartadserverBidAdapter.js +1 -1
  96. package/dist/smartxBidAdapter.js +1 -1
  97. package/dist/smilewantedBidAdapter.js +1 -1
  98. package/dist/sonobiBidAdapter.js +1 -1
  99. package/dist/sovrnAnalyticsAdapter.js +1 -1
  100. package/dist/sovrnBidAdapter.js +1 -1
  101. package/dist/sspBCBidAdapter.js +1 -1
  102. package/dist/sublimeBidAdapter.js +1 -1
  103. package/dist/synacormediaBidAdapter.js +1 -1
  104. package/dist/targetVideoBidAdapter.js +1 -1
  105. package/dist/teadsBidAdapter.js +1 -1
  106. package/dist/trionBidAdapter.js +1 -1
  107. package/dist/tripleliftBidAdapter.js +1 -1
  108. package/dist/ttdBidAdapter.js +1 -1
  109. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  110. package/dist/underdogmediaBidAdapter.js +1 -1
  111. package/dist/undertoneBidAdapter.js +1 -1
  112. package/dist/userId.js +1 -1
  113. package/dist/vidazooBidAdapter.js +1 -1
  114. package/dist/videobyteBidAdapter.js +1 -1
  115. package/dist/visxBidAdapter.js +1 -1
  116. package/dist/vuukleBidAdapter.js +1 -1
  117. package/dist/widespaceBidAdapter.js +1 -1
  118. package/dist/winrBidAdapter.js +1 -1
  119. package/dist/yahoosspBidAdapter.js +1 -1
  120. package/dist/yieldmoBidAdapter.js +1 -1
  121. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  122. package/integrationExamples/gpt/mgidRtdProvider_example.html +143 -0
  123. package/modules/.submodules.json +1 -0
  124. package/modules/admaticBidAdapter.js +147 -0
  125. package/modules/admaticBidAdapter.md +48 -0
  126. package/modules/amxBidAdapter.js +1 -0
  127. package/modules/connectIdSystem.js +36 -23
  128. package/modules/connectIdSystem.md +3 -2
  129. package/modules/growthCodeIdSystem.js +9 -5
  130. package/modules/gumgumBidAdapter.js +4 -0
  131. package/modules/ixBidAdapter.js +30 -7
  132. package/modules/kueezRtbBidAdapter.js +278 -0
  133. package/modules/kueezRtbBidAdapter.md +35 -0
  134. package/modules/magniteAnalyticsAdapter.js +6 -1
  135. package/modules/mgidRtdProvider.js +190 -0
  136. package/modules/mgidRtdProvider.md +51 -0
  137. package/modules/permutiveRtdProvider.js +2 -1
  138. package/modules/permutiveRtdProvider.md +36 -1
  139. package/modules/pubmaticBidAdapter.js +21 -29
  140. package/modules/tripleliftBidAdapter.js +1 -1
  141. package/modules/userId/eids.js +3 -10
  142. package/package.json +8 -8
  143. package/src/adRendering.js +1 -1
  144. package/src/adloader.js +1 -0
  145. package/src/auction.js +1 -1
  146. package/src/prebid.js +83 -79
  147. package/test/spec/auctionmanager_spec.js +9 -0
  148. package/test/spec/modules/admaticBidAdapter_spec.js +46 -0
  149. package/test/spec/modules/connectIdSystem_spec.js +175 -5
  150. package/test/spec/modules/eids_spec.js +10 -7
  151. package/test/spec/modules/ftrackIdSystem_spec.js +34 -22
  152. package/test/spec/modules/gumgumBidAdapter_spec.js +15 -0
  153. package/test/spec/modules/ixBidAdapter_spec.js +203 -0
  154. package/test/spec/modules/kueezRtbBidAdapter_spec.js +396 -0
  155. package/test/spec/modules/magniteAnalyticsAdapter_spec.js +26 -0
  156. package/test/spec/modules/mgidRtdProvider_spec.js +366 -0
  157. package/test/spec/modules/permutiveRtdProvider_spec.js +64 -5
  158. package/test/spec/modules/tripleliftBidAdapter_spec.js +14 -0
  159. package/test/spec/unit/pbjs_api_spec.js +17 -1
@@ -0,0 +1,396 @@
1
+ import {expect} from 'chai';
2
+ import {
3
+ spec as adapter,
4
+ SUPPORTED_ID_SYSTEMS,
5
+ createDomain,
6
+ hashCode,
7
+ extractPID,
8
+ extractCID,
9
+ extractSubDomain,
10
+ getStorageItem,
11
+ setStorageItem,
12
+ tryParseJSON,
13
+ getUniqueDealId,
14
+ } from 'modules/kueezRtbBidAdapter.js';
15
+ import * as utils from 'src/utils.js';
16
+ import {version} from 'package.json';
17
+ import {useFakeTimers} from 'sinon';
18
+
19
+ const SUB_DOMAIN = 'exchange';
20
+
21
+ const BID = {
22
+ 'bidId': '2d52001cabd527',
23
+ 'adUnitCode': 'div-gpt-ad-12345-0',
24
+ 'params': {
25
+ 'subDomain': SUB_DOMAIN,
26
+ 'cId': '59db6b3b4ffaa70004f45cdc',
27
+ 'pId': '59ac17c192832d0011283fe3',
28
+ 'bidFloor': 0.1,
29
+ 'ext': {
30
+ 'param1': 'loremipsum',
31
+ 'param2': 'dolorsitamet'
32
+ }
33
+ },
34
+ 'placementCode': 'div-gpt-ad-1460505748561-0',
35
+ 'transactionId': 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf',
36
+ 'sizes': [[300, 250], [300, 600]],
37
+ 'bidderRequestId': '1fdb5ff1b6eaa7',
38
+ 'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a',
39
+ 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc'
40
+ };
41
+
42
+ const BIDDER_REQUEST = {
43
+ 'gdprConsent': {
44
+ 'consentString': 'consent_string',
45
+ 'gdprApplies': true
46
+ },
47
+ 'uspConsent': 'consent_string',
48
+ 'refererInfo': {
49
+ 'page': 'https://www.greatsite.com',
50
+ 'ref': 'https://www.somereferrer.com'
51
+ }
52
+ };
53
+
54
+ const SERVER_RESPONSE = {
55
+ body: {
56
+ cid: 'testcid123',
57
+ results: [{
58
+ 'ad': '<iframe>console.log("hello world")</iframe>',
59
+ 'price': 0.8,
60
+ 'creativeId': '12610997325162499419',
61
+ 'exp': 30,
62
+ 'width': 300,
63
+ 'height': 250,
64
+ 'advertiserDomains': ['securepubads.g.doubleclick.net'],
65
+ 'cookies': [{
66
+ 'src': 'https://sync.com',
67
+ 'type': 'iframe'
68
+ }, {
69
+ 'src': 'https://sync.com',
70
+ 'type': 'img'
71
+ }]
72
+ }]
73
+ }
74
+ };
75
+
76
+ const REQUEST = {
77
+ data: {
78
+ width: 300,
79
+ height: 250,
80
+ bidId: '2d52001cabd527'
81
+ }
82
+ };
83
+
84
+ function getTopWindowQueryParams() {
85
+ try {
86
+ const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true});
87
+ return parsedUrl.search;
88
+ } catch (e) {
89
+ return '';
90
+ }
91
+ }
92
+
93
+ describe('KueezRtbBidAdapter', function () {
94
+ describe('validtae spec', function () {
95
+ it('exists and is a function', function () {
96
+ expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function');
97
+ });
98
+
99
+ it('exists and is a function', function () {
100
+ expect(adapter.buildRequests).to.exist.and.to.be.a('function');
101
+ });
102
+
103
+ it('exists and is a function', function () {
104
+ expect(adapter.interpretResponse).to.exist.and.to.be.a('function');
105
+ });
106
+
107
+ it('exists and is a function', function () {
108
+ expect(adapter.getUserSyncs).to.exist.and.to.be.a('function');
109
+ });
110
+
111
+ it('exists and is a string', function () {
112
+ expect(adapter.code).to.exist.and.to.be.a('string');
113
+ });
114
+ });
115
+
116
+ describe('validate bid requests', function () {
117
+ it('should require cId', function () {
118
+ const isValid = adapter.isBidRequestValid({
119
+ params: {
120
+ pId: 'pid'
121
+ }
122
+ });
123
+ expect(isValid).to.be.false;
124
+ });
125
+
126
+ it('should require pId', function () {
127
+ const isValid = adapter.isBidRequestValid({
128
+ params: {
129
+ cId: 'cid'
130
+ }
131
+ });
132
+ expect(isValid).to.be.false;
133
+ });
134
+
135
+ it('should validate correctly', function () {
136
+ const isValid = adapter.isBidRequestValid({
137
+ params: {
138
+ cId: 'cid',
139
+ pId: 'pid'
140
+ }
141
+ });
142
+ expect(isValid).to.be.true;
143
+ });
144
+ });
145
+
146
+ describe('build requests', function () {
147
+ let sandbox;
148
+ before(function () {
149
+ $$PREBID_GLOBAL$$.bidderSettings = {
150
+ kueezrtb: {
151
+ storageAllowed: true
152
+ }
153
+ };
154
+ sandbox = sinon.sandbox.create();
155
+ sandbox.stub(Date, 'now').returns(1000);
156
+ });
157
+
158
+ it('should build request for each size', function () {
159
+ const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page);
160
+ const requests = adapter.buildRequests([BID], BIDDER_REQUEST);
161
+ expect(requests).to.have.length(1);
162
+ expect(requests[0]).to.deep.equal({
163
+ method: 'POST',
164
+ url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`,
165
+ data: {
166
+ gdprConsent: 'consent_string',
167
+ gdpr: 1,
168
+ usPrivacy: 'consent_string',
169
+ sizes: ['300x250', '300x600'],
170
+ url: 'https%3A%2F%2Fwww.greatsite.com',
171
+ referrer: 'https://www.somereferrer.com',
172
+ cb: 1000,
173
+ bidFloor: 0.1,
174
+ bidId: '2d52001cabd527',
175
+ adUnitCode: 'div-gpt-ad-12345-0',
176
+ publisherId: '59ac17c192832d0011283fe3',
177
+ uniqueDealId: `${hashUrl}_${Date.now().toString()}`,
178
+ bidderVersion: adapter.version,
179
+ prebidVersion: version,
180
+ schain: BID.schain,
181
+ res: `${window.top.screen.width}x${window.top.screen.height}`,
182
+ uqs: getTopWindowQueryParams(),
183
+ 'ext.param1': 'loremipsum',
184
+ 'ext.param2': 'dolorsitamet',
185
+ }
186
+ });
187
+ });
188
+
189
+ after(function () {
190
+ $$PREBID_GLOBAL$$.bidderSettings = {};
191
+ sandbox.restore();
192
+ });
193
+ });
194
+ describe('getUserSyncs', function () {
195
+ it('should have valid user sync with iframeEnabled', function () {
196
+ const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
197
+
198
+ expect(result).to.deep.equal([{
199
+ type: 'iframe',
200
+ url: 'https://sync.kueezrtb.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy='
201
+ }]);
202
+ });
203
+
204
+ it('should have valid user sync with cid on response', function () {
205
+ const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]);
206
+ expect(result).to.deep.equal([{
207
+ type: 'iframe',
208
+ url: 'https://sync.kueezrtb.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy='
209
+ }]);
210
+ });
211
+
212
+ it('should have valid user sync with pixelEnabled', function () {
213
+ const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]);
214
+
215
+ expect(result).to.deep.equal([{
216
+ 'url': 'https://sync.kueezrtb.com/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=',
217
+ 'type': 'image'
218
+ }]);
219
+ })
220
+ });
221
+
222
+ describe('interpret response', function () {
223
+ it('should return empty array when there is no response', function () {
224
+ const responses = adapter.interpretResponse(null);
225
+ expect(responses).to.be.empty;
226
+ });
227
+
228
+ it('should return empty array when there is no ad', function () {
229
+ const responses = adapter.interpretResponse({price: 1, ad: ''});
230
+ expect(responses).to.be.empty;
231
+ });
232
+
233
+ it('should return empty array when there is no price', function () {
234
+ const responses = adapter.interpretResponse({price: null, ad: 'great ad'});
235
+ expect(responses).to.be.empty;
236
+ });
237
+
238
+ it('should return an array of interpreted responses', function () {
239
+ const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST);
240
+ expect(responses).to.have.length(1);
241
+ expect(responses[0]).to.deep.equal({
242
+ requestId: '2d52001cabd527',
243
+ cpm: 0.8,
244
+ width: 300,
245
+ height: 250,
246
+ creativeId: '12610997325162499419',
247
+ currency: 'USD',
248
+ netRevenue: true,
249
+ ttl: 30,
250
+ ad: '<iframe>console.log("hello world")</iframe>',
251
+ meta: {
252
+ advertiserDomains: ['securepubads.g.doubleclick.net']
253
+ }
254
+ });
255
+ });
256
+
257
+ it('should take default TTL', function () {
258
+ const serverResponse = utils.deepClone(SERVER_RESPONSE);
259
+ delete serverResponse.body.results[0].exp;
260
+ const responses = adapter.interpretResponse(serverResponse, REQUEST);
261
+ expect(responses).to.have.length(1);
262
+ expect(responses[0].ttl).to.equal(300);
263
+ });
264
+ });
265
+
266
+ describe('user id system', function () {
267
+ Object.keys(SUPPORTED_ID_SYSTEMS).forEach((idSystemProvider) => {
268
+ const id = Date.now().toString();
269
+ const bid = utils.deepClone(BID);
270
+
271
+ const userId = (function () {
272
+ switch (idSystemProvider) {
273
+ case 'lipb':
274
+ return {lipbid: id};
275
+ case 'parrableId':
276
+ return {eid: id};
277
+ case 'id5id':
278
+ return {uid: id};
279
+ default:
280
+ return id;
281
+ }
282
+ })();
283
+
284
+ bid.userId = {
285
+ [idSystemProvider]: userId
286
+ };
287
+
288
+ it(`should include 'uid.${idSystemProvider}' in request params`, function () {
289
+ const requests = adapter.buildRequests([bid], BIDDER_REQUEST);
290
+ expect(requests[0].data[`uid.${idSystemProvider}`]).to.equal(id);
291
+ });
292
+ });
293
+ });
294
+
295
+ describe('alternate param names extractors', function () {
296
+ it('should return undefined when param not supported', function () {
297
+ const cid = extractCID({'c_id': '1'});
298
+ const pid = extractPID({'p_id': '1'});
299
+ const subDomain = extractSubDomain({'sub_domain': 'prebid'});
300
+ expect(cid).to.be.undefined;
301
+ expect(pid).to.be.undefined;
302
+ expect(subDomain).to.be.undefined;
303
+ });
304
+
305
+ it('should return value when param supported', function () {
306
+ const cid = extractCID({'cID': '1'});
307
+ const pid = extractPID({'Pid': '2'});
308
+ const subDomain = extractSubDomain({'subDOMAIN': 'prebid'});
309
+ expect(cid).to.be.equal('1');
310
+ expect(pid).to.be.equal('2');
311
+ expect(subDomain).to.be.equal('prebid');
312
+ });
313
+ });
314
+
315
+ describe('unique deal id', function () {
316
+ before(function () {
317
+ $$PREBID_GLOBAL$$.bidderSettings = {
318
+ kueezrtb: {
319
+ storageAllowed: true
320
+ }
321
+ };
322
+ });
323
+ after(function () {
324
+ $$PREBID_GLOBAL$$.bidderSettings = {};
325
+ });
326
+ const key = 'myKey';
327
+ let uniqueDealId;
328
+ beforeEach(() => {
329
+ uniqueDealId = getUniqueDealId(key, 0);
330
+ })
331
+
332
+ it('should get current unique deal id', function (done) {
333
+ // waiting some time so `now` will become past
334
+ setTimeout(() => {
335
+ const current = getUniqueDealId(key);
336
+ expect(current).to.be.equal(uniqueDealId);
337
+ done();
338
+ }, 200);
339
+ });
340
+
341
+ it('should get new unique deal id on expiration', function (done) {
342
+ setTimeout(() => {
343
+ const current = getUniqueDealId(key, 100);
344
+ expect(current).to.not.be.equal(uniqueDealId);
345
+ done();
346
+ }, 200)
347
+ });
348
+ });
349
+
350
+ describe('storage utils', function () {
351
+ before(function () {
352
+ $$PREBID_GLOBAL$$.bidderSettings = {
353
+ kueezrtb: {
354
+ storageAllowed: true
355
+ }
356
+ };
357
+ });
358
+ after(function () {
359
+ $$PREBID_GLOBAL$$.bidderSettings = {};
360
+ });
361
+ it('should get value from storage with create param', function () {
362
+ const now = Date.now();
363
+ const clock = useFakeTimers({
364
+ shouldAdvanceTime: true,
365
+ now
366
+ });
367
+ setStorageItem('myKey', 2020);
368
+ const {value, created} = getStorageItem('myKey');
369
+ expect(created).to.be.equal(now);
370
+ expect(value).to.be.equal(2020);
371
+ expect(typeof value).to.be.equal('number');
372
+ expect(typeof created).to.be.equal('number');
373
+ clock.restore();
374
+ });
375
+
376
+ it('should get external stored value', function () {
377
+ const value = 'superman'
378
+ window.localStorage.setItem('myExternalKey', value);
379
+ const item = getStorageItem('myExternalKey');
380
+ expect(item).to.be.equal(value);
381
+ });
382
+
383
+ it('should parse JSON value', function () {
384
+ const data = JSON.stringify({event: 'send'});
385
+ const {event} = tryParseJSON(data);
386
+ expect(event).to.be.equal('send');
387
+ });
388
+
389
+ it('should get original value on parse fail', function () {
390
+ const value = 21;
391
+ const parsed = tryParseJSON(value);
392
+ expect(typeof parsed).to.be.equal('number');
393
+ expect(parsed).to.be.equal(value);
394
+ });
395
+ });
396
+ });
@@ -602,6 +602,32 @@ describe('magnite analytics adapter', function () {
602
602
  let message = JSON.parse(server.requests[0].requestBody);
603
603
  expect(message.auctions[0].adUnits[0].bids[0].bidResponse.adomains).to.deep.equal(test.expected);
604
604
  });
605
+
606
+ // Network Id tests
607
+ [
608
+ { input: 'magnite.com', expected: 'magnite.com' },
609
+ { input: 12345, expected: '12345' },
610
+ { input: ['magnite.com', 12345], expected: 'magnite.com,12345' }
611
+ ].forEach((test, index) => {
612
+ it(`should handle networkId correctly - #${index + 1}`, function () {
613
+ events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
614
+ events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
615
+
616
+ let bidResponse = utils.deepClone(MOCK.BID_RESPONSE);
617
+ bidResponse.meta = {
618
+ networkId: test.input
619
+ };
620
+
621
+ events.emit(BID_RESPONSE, bidResponse);
622
+ events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
623
+ events.emit(AUCTION_END, MOCK.AUCTION_END);
624
+ events.emit(BID_WON, MOCK.BID_WON);
625
+ clock.tick(rubiConf.analyticsBatchTimeout + 1000);
626
+
627
+ let message = JSON.parse(server.requests[0].requestBody);
628
+ expect(message.auctions[0].adUnits[0].bids[0].bidResponse.networkId).to.equal(test.expected);
629
+ });
630
+ });
605
631
  });
606
632
 
607
633
  describe('with session handling', function () {