• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prebid / Prebid.js / 16279920599

14 Jul 2025 11:12PM UTC coverage: 96.2% (-0.002%) from 96.202%
16279920599

push

github

412021
web-flow
maintenance: enforce no-global-assign in tests (#13575)

39190 of 48203 branches covered (81.3%)

12 of 12 new or added lines in 1 file covered. (100.0%)

27 existing lines in 19 files now uncovered.

192751 of 200364 relevant lines covered (96.2%)

87.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.55
/test/spec/modules/yieldoneBidAdapter_spec.js
1
import { expect } from 'chai';
2
import { spec } from 'modules/yieldoneBidAdapter.js';
3
import { newBidder } from 'src/adapters/bidderFactory.js';
4
import { getBrowser, getOS } from '../../../libraries/userAgentUtils/index.js';
5
import { browserTypes, osTypes } from '../../../libraries/userAgentUtils/userAgentTypes.enums.js';
6

7
const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid';
1✔
8
const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync';
1✔
9
const VIDEO_PLAYER_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstview/js/dac-video-prebid.min.js';
1✔
10

11
const DEFAULT_VIDEO_SIZE = {w: 640, h: 360};
1✔
12

13
describe('yieldoneBidAdapter', function () {
1✔
14
  const adapter = newBidder(spec);
1✔
15

16
  describe('isBidRequestValid', function () {
1✔
17
    const bid = {
1✔
18
      'bidder': 'yieldone',
19
      'params': {
20
        placementId: '36891'
21
      },
22
      'adUnitCode': 'adunit-code',
23
      'sizes': [[300, 250], [336, 280]],
24
      'bidId': '23beaa6af6cdde',
25
      'bidderRequestId': '19c0c1efdf37e7',
26
      'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
27
    };
28

29
    it('should return true when required params found', function () {
1✔
30
      expect(spec.isBidRequestValid(bid)).to.equal(true);
1✔
31
    });
32

33
    it('should return false when placementId not passed correctly', function () {
1✔
34
      bid.params.placementId = '';
1✔
35
      expect(spec.isBidRequestValid(bid)).to.equal(false);
1✔
36
    });
37

38
    it('should return false when require params are not passed', function () {
1✔
39
      const invalidBid = Object.assign({}, bid);
1✔
40
      invalidBid.params = {};
1✔
41
      expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
1✔
42
    });
43
  });
44

45
  describe('buildRequests', function () {
1✔
46
    const bidderRequest = {
1✔
47
      refererInfo: {
48
        numIframes: 0,
49
        reachedTop: true,
50
        referer: 'http://example.com',
51
        stack: ['http://example.com']
52
      }
53
    };
54

55
    describe('Basic', function () {
1✔
56
      const bidRequests = [
1✔
57
        {
58
          'bidder': 'yieldone',
59
          'params': {placementId: '36891'},
60
          'adUnitCode': 'adunit-code1',
61
          'bidId': '23beaa6af6cdde',
62
          'bidderRequestId': '19c0c1efdf37e7',
63
          'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
64
        },
65
        {
66
          'bidder': 'yieldone',
67
          'params': {placementId: '47919'},
68
          'adUnitCode': 'adunit-code2',
69
          'bidId': '382091349b149f"',
70
          'bidderRequestId': '"1f9c98192de251"',
71
          'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1',
72
        }
73
      ];
74
      const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
75

76
      it('sends bid request to our endpoint via GET', function () {
1✔
77
        expect(request[0].method).to.equal('GET');
1✔
78
        expect(request[1].method).to.equal('GET');
1✔
79
      });
80
      it('attaches source and version to endpoint URL as query params', function () {
1✔
81
        expect(request[0].url).to.equal(ENDPOINT);
1✔
82
        expect(request[1].url).to.equal(ENDPOINT);
1✔
83
      });
84
      it('adUnitCode should be sent as uc parameters on any requests', function () {
1✔
85
        expect(request[0].data.uc).to.equal('adunit-code1');
1✔
86
        expect(request[1].data.uc).to.equal('adunit-code2');
1✔
87
      });
88
    });
89

90
    describe('Old Format', function () {
1✔
91
      const bidRequests = [
1✔
92
        {
93
          params: {placementId: '0'},
94
          mediaType: 'banner',
95
          sizes: [[300, 250], [336, 280]],
96
        },
97
        {
98
          params: {placementId: '1'},
99
          mediaType: 'banner',
100
          sizes: [[336, 280]],
101
        },
102
        {
103
          // It doesn't actually exist.
104
          params: {placementId: '2'},
105
        },
106
        {
107
          params: {placementId: '3'},
108
          mediaType: 'video',
109
          sizes: [[1280, 720], [1920, 1080]],
110
        },
111
        {
112
          params: {placementId: '4'},
113
          mediaType: 'video',
114
          sizes: [[1920, 1080]],
115
        },
116
        {
117
          params: {placementId: '5'},
118
          mediaType: 'video',
119
        },
120
      ];
121
      const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
122

123
      it('parameter sz has more than one size on banner requests', function () {
1✔
124
        expect(request[0].data.sz).to.equal('300x250,336x280');
1✔
125
        expect(request[1].data.sz).to.equal('336x280');
1✔
126
        expect(request[2].data.sz).to.equal('');
1✔
127
        expect(request[3].data).to.not.have.property('sz');
1✔
128
        expect(request[4].data).to.not.have.property('sz');
1✔
129
        expect(request[5].data).to.not.have.property('sz');
1✔
130
      });
131

132
      it('width and height should be set as separate parameters on outstream requests', function () {
1✔
133
        expect(request[0].data).to.not.have.property('w');
1✔
134
        expect(request[1].data).to.not.have.property('w');
1✔
135
        expect(request[2].data).to.not.have.property('w');
1✔
136
        expect(request[3].data.w).to.equal(1280);
1✔
137
        expect(request[3].data.h).to.equal(720);
1✔
138
        expect(request[4].data.w).to.equal(1920);
1✔
139
        expect(request[4].data.h).to.equal(1080);
1✔
140
        expect(request[5].data.w).to.equal(DEFAULT_VIDEO_SIZE.w);
1✔
141
        expect(request[5].data.h).to.equal(DEFAULT_VIDEO_SIZE.h);
1✔
142
      });
143
    });
144

145
    describe('Single Format', function () {
1✔
146
      const bidRequests = [
1✔
147
        {
148
          params: {placementId: '0'},
149
          mediaTypes: {
150
            banner: {
151
              sizes: [[300, 250], [336, 280]],
152
            },
153
          },
154
        },
155
        {
156
          params: {placementId: '1'},
157
          mediaTypes: {
158
            banner: {
159
              sizes: [[336, 280]],
160
            },
161
          },
162
        },
163
        {
164
          // It doesn't actually exist.
165
          params: {placementId: '2'},
166
          mediaTypes: {
167
            banner: {
168
            },
169
          },
170
        },
171
        {
172
          params: {placementId: '3'},
173
          mediaTypes: {
174
            video: {
175
              context: 'outstream',
176
              playerSize: [[1280, 720], [1920, 1080]],
177
            },
178
          },
179
        },
180
        {
181
          params: {placementId: '4'},
182
          mediaTypes: {
183
            video: {
184
              context: 'outstream',
185
              playerSize: [1920, 1080],
186
            },
187
          },
188
        },
189
        {
190
          params: {placementId: '5'},
191
          mediaTypes: {
192
            video: {
193
              context: 'outstream',
194
            },
195
          },
196
        },
197
      ];
198
      const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
199

200
      it('parameter sz has more than one size on banner requests', function () {
1✔
201
        expect(request[0].data.sz).to.equal('300x250,336x280');
1✔
202
        expect(request[1].data.sz).to.equal('336x280');
1✔
203
        expect(request[2].data.sz).to.equal('');
1✔
204
        expect(request[3].data).to.not.have.property('sz');
1✔
205
        expect(request[4].data).to.not.have.property('sz');
1✔
206
        expect(request[5].data).to.not.have.property('sz');
1✔
207
      });
208

209
      it('width and height should be set as separate parameters on outstream requests', function () {
1✔
210
        expect(request[0].data).to.not.have.property('w');
1✔
211
        expect(request[0].data).to.not.have.property('h');
1✔
212
        expect(request[1].data).to.not.have.property('w');
1✔
213
        expect(request[1].data).to.not.have.property('h');
1✔
214
        expect(request[2].data).to.not.have.property('w');
1✔
215
        expect(request[2].data).to.not.have.property('h');
1✔
216
        expect(request[3].data.w).to.equal(1280);
1✔
217
        expect(request[3].data.h).to.equal(720);
1✔
218
        expect(request[4].data.w).to.equal(1920);
1✔
219
        expect(request[4].data.h).to.equal(1080);
1✔
220
        expect(request[5].data.w).to.equal(DEFAULT_VIDEO_SIZE.w);
1✔
221
        expect(request[5].data.h).to.equal(DEFAULT_VIDEO_SIZE.h);
1✔
222
      });
223
    });
224

225
    describe('Multiple Format', function () {
1✔
226
      const bidRequests = [
1✔
227
        {
228
          // It will be treated as a banner.
229
          params: {
230
            placementId: '0',
231
          },
232
          mediaTypes: {
233
            banner: {
234
              sizes: [[300, 250], [336, 280]],
235
            },
236
            video: {
237
              context: 'outstream',
238
              playerSize: [1920, 1080],
239
            },
240
          },
241
        },
242
        {
243
          // It will be treated as a video.
244
          params: {
245
            placementId: '1',
246
            playerParams: {},
247
          },
248
          mediaTypes: {
249
            banner: {
250
              sizes: [[300, 250], [336, 280]],
251
            },
252
            video: {
253
              context: 'outstream',
254
              playerSize: [1920, 1080],
255
            },
256
          },
257
        },
258
      ];
259
      const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
260

261
      it('parameter sz has more than one size on banner requests', function () {
1✔
262
        expect(request[0].data.sz).to.equal('300x250,336x280');
1✔
263
        expect(request[1].data).to.not.have.property('sz');
1✔
264
      });
265

266
      it('width and height should be set as separate parameters on outstream requests', function () {
1✔
267
        expect(request[0].data).to.not.have.property('w');
1✔
268
        expect(request[0].data).to.not.have.property('h');
1✔
269
        expect(request[1].data.w).to.equal(1920);
1✔
270
        expect(request[1].data.h).to.equal(1080);
1✔
271
      });
272
    });
273

274
    describe('1x1 Format', function () {
1✔
275
      const bidRequests = [
1✔
276
        {
277
          // It will be treated as a banner.
278
          params: {
279
            placementId: '0',
280
          },
281
          mediaTypes: {
282
            banner: {
283
              sizes: [[300, 250], [336, 280]],
284
            },
285
            video: {
286
              context: 'outstream',
287
              playerSize: [[1, 1]],
288
            },
289
          },
290
        },
291
        {
292
          // It will be treated as a video.
293
          params: {
294
            placementId: '1',
295
            playerParams: {},
296
            playerSize: [1920, 1080],
297
          },
298
          mediaTypes: {
299
            banner: {
300
              sizes: [[300, 250], [336, 280]],
301
            },
302
            video: {
303
              context: 'outstream',
304
              playerSize: [[1, 1]],
305
            },
306
          },
307
        },
308
        {
309
          // It will be treated as a video.
310
          params: {
311
            placementId: '2',
312
            playerParams: {},
313
          },
314
          mediaTypes: {
315
            banner: {
316
              sizes: [[300, 250], [336, 280]],
317
            },
318
            video: {
319
              context: 'outstream',
320
              playerSize: [[1, 1]],
321
            },
322
          },
323
        },
324
      ];
325
      const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
326

327
      it('parameter sz has more than one size on banner requests', function () {
1✔
328
        expect(request[0].data.sz).to.equal('300x250,336x280');
1✔
329
        expect(request[1].data).to.not.have.property('sz');
1✔
330
        expect(request[2].data).to.not.have.property('sz');
1✔
331
      });
332

333
      it('width and height should be set as separate parameters on outstream requests', function () {
1✔
334
        expect(request[0].data).to.not.have.property('w');
1✔
335
        expect(request[0].data).to.not.have.property('h');
1✔
336
        expect(request[1].data.w).to.equal(1920);
1✔
337
        expect(request[1].data.h).to.equal(1080);
1✔
338
        expect(request[2].data.w).to.equal(DEFAULT_VIDEO_SIZE.w);
1✔
339
        expect(request[2].data.h).to.equal(DEFAULT_VIDEO_SIZE.h);
1✔
340
      });
341
    });
342

343
    describe('LiveRampID', function () {
1✔
344
      it('dont send LiveRampID if undefined', function () {
1✔
345
        const bidRequests = [
1✔
346
          {
347
            params: {placementId: '0'},
348
          },
349
          {
350
            params: {placementId: '1'},
351
            userId: {},
352
          },
353
          {
354
            params: {placementId: '2'},
355
            userId: undefined,
356
          },
357
        ];
358
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
359
        expect(request[0].data).to.not.have.property('lr_env');
1✔
360
        expect(request[1].data).to.not.have.property('lr_env');
1✔
361
        expect(request[2].data).to.not.have.property('lr_env');
1✔
362
      });
363

364
      it('should send LiveRampID if available', function () {
1✔
365
        const bidRequests = [
1✔
366
          {
367
            params: {placementId: '0'},
368
            userId: {idl_env: 'idl_env_sample'},
369
          },
370
        ];
371
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
372
        expect(request[0].data.lr_env).to.equal('idl_env_sample');
1✔
373
      });
374
    });
375

376
    describe('IMID', function () {
1✔
377
      it('dont send IMID if undefined', function () {
1✔
378
        const bidRequests = [
1✔
379
          {
380
            params: {placementId: '0'},
381
          },
382
          {
383
            params: {placementId: '1'},
384
            userId: {},
385
          },
386
          {
387
            params: {placementId: '2'},
388
            userId: undefined,
389
          },
390
        ];
391
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
392
        expect(request[0].data).to.not.have.property('imuid');
1✔
393
        expect(request[1].data).to.not.have.property('imuid');
1✔
394
        expect(request[2].data).to.not.have.property('imuid');
1✔
395
      });
396

397
      it('should send IMID if available', function () {
1✔
398
        const bidRequests = [
1✔
399
          {
400
            params: {placementId: '0'},
401
            userId: {imuid: 'imuid_sample'},
402
          },
403
        ];
404
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
405
        expect(request[0].data.imuid).to.equal('imuid_sample');
1✔
406
      });
407
    });
408

409
    describe('DAC ID', function () {
1✔
410
      it('dont send DAC ID if undefined', function () {
1✔
411
        const bidRequests = [
1✔
412
          {
413
            params: {placementId: '0'},
414
          },
415
          {
416
            params: {placementId: '1'},
417
            userId: {},
418
          },
419
          {
420
            params: {placementId: '2'},
421
            userId: undefined,
422
          },
423
        ];
424
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
425
        expect(request[0].data).to.not.have.property('dac_id');
1✔
426
        expect(request[1].data).to.not.have.property('dac_id');
1✔
427
        expect(request[2].data).to.not.have.property('dac_id');
1✔
428
        expect(request[0].data).to.not.have.property('fuuid');
1✔
429
        expect(request[1].data).to.not.have.property('fuuid');
1✔
430
        expect(request[2].data).to.not.have.property('fuuid');
1✔
431
      });
432

433
      it('should send DAC ID if available', function () {
1✔
434
        const bidRequests = [
1✔
435
          {
436
            params: {placementId: '0'},
437
            userId: {dacId: {fuuid: 'fuuid_sample', id: 'dacId_sample'}},
438
          },
439
        ];
440
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
441
        expect(request[0].data.fuuid).to.equal('fuuid_sample');
1✔
442
        expect(request[0].data.dac_id).to.equal('dacId_sample');
1✔
443
      });
444
    });
445

446
    describe('ID5', function () {
1✔
447
      it('dont send ID5 if undefined', function () {
1✔
448
        const bidRequests = [
1✔
449
          {
450
            params: {placementId: '0'},
451
          },
452
          {
453
            params: {placementId: '1'},
454
            userId: {},
455
          },
456
          {
457
            params: {placementId: '2'},
458
            userId: undefined,
459
          },
460
        ];
461
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
462
        expect(request[0].data).to.not.have.property('id5Id');
1✔
463
        expect(request[1].data).to.not.have.property('id5Id');
1✔
464
        expect(request[2].data).to.not.have.property('id5Id');
1✔
465
      });
466

467
      it('should send ID5 if available', function () {
1✔
468
        const bidRequests = [
1✔
469
          {
470
            params: {placementId: '0'},
471
            userId: {id5id: {uid: 'id5id_sample'}},
472
          },
473
        ];
474
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
475
        expect(request[0].data.id5Id).to.equal('id5id_sample');
1✔
476
      });
477
    });
478

479
    describe('UID2.0', function () {
1✔
480
      it('dont send UID2.0 if undefined', function () {
1✔
481
        const bidRequests = [
1✔
482
          {
483
            params: {placementId: '0'},
484
          },
485
          {
486
            params: {placementId: '1'},
487
            userId: {},
488
          },
489
          {
490
            params: {placementId: '2'},
491
            userId: undefined,
492
          },
493
        ];
494
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
495
        expect(request[0].data).to.not.have.property('uid2id');
1✔
496
        expect(request[1].data).to.not.have.property('uid2id');
1✔
497
        expect(request[2].data).to.not.have.property('uid2id');
1✔
498
      });
499

500
      it('should send UID2.0 if available', function () {
1✔
501
        const bidRequests = [
1✔
502
          {
503
            params: {placementId: '0'},
504
            userId: {uid2: {id: 'uid2_sample'}},
505
          },
506
        ];
507
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
508
        expect(request[0].data.uid2id).to.equal('uid2_sample');
1✔
509
      });
510
    });
511

512
    describe('GPID', function () {
1✔
513
      it('dont send GPID if undefined', function () {
1✔
514
        const bidRequests = [
1✔
515
          {
516
            params: {placementId: '0'},
517
          },
518
          {
519
            params: {placementId: '1'},
520
            ortb2Imp: {},
521
          },
522
          {
523
            params: {placementId: '2'},
524
            ortb2Imp: undefined,
525
          },
526
          {
527
            params: {placementId: '3'},
528
            ortb2Imp: {ext: {gpid: undefined, data: {pubadslot: 'aaa'}}},
529
          },
530
        ];
531
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
532
        expect(request[0].data).to.not.have.property('gpid');
1✔
533
        expect(request[1].data).to.not.have.property('gpid');
1✔
534
        expect(request[2].data).to.not.have.property('gpid');
1✔
535
        expect(request[3].data).to.not.have.property('gpid');
1✔
536
      });
537

538
      it('should send GPID if available', function () {
1✔
539
        const bidRequests = [
1✔
540
          {
541
            params: {placementId: '0'},
542
            ortb2Imp: {ext: {gpid: 'gpid_sample'}},
543
          },
544
        ];
545
        const request = spec.buildRequests(bidRequests, bidderRequest);
1✔
546
        expect(request[0].data.ext).to.be.not.null;
1✔
547
        expect(request[0].data).to.have.property('gpid');
1✔
548
        expect(request[0].data.gpid).to.equal('gpid_sample');
1✔
549
      });
550
    });
551
  });
552

553
  describe('interpretResponse', function () {
1✔
554
    const bidRequestBanner = [
1✔
555
      {
556
        'method': 'GET',
557
        'url': 'https://y.one.impact-ad.jp/h_bid',
558
        'data': {
559
          'v': 'hb1',
560
          'p': '36891',
561
          'sz': '300x250,336x280',
562
          'cb': 12892917383,
563
          'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836',
564
          'uid': '23beaa6af6cdde',
565
          't': 'i',
566
          'language': 'ja',
567
          'screen_size': '1440x900'
568
        }
569
      }
570
    ];
571

572
    const serverResponseBanner = {
1✔
573
      body: {
574
        'adTag': '<!-- adtag -->',
575
        'uid': '23beaa6af6cdde',
576
        'height': 250,
577
        'width': 300,
578
        'cpm': 0.0536616,
579
        'crid': '2494768',
580
        'currency': 'JPY',
581
        'statusMessage': 'Bid available',
582
        'dealId': 'P1-FIX-7800-DSP-MON',
583
        'adomain': [
584
          'www.example.com'
585
        ],
586
      }
587
    };
588

589
    it('should get the correct bid response for banner', function () {
1✔
590
      const expectedResponse = [{
1✔
591
        'requestId': '23beaa6af6cdde',
592
        'cpm': 53.6616,
593
        'width': 300,
594
        'height': 250,
595
        'creativeId': '2494768',
596
        'dealId': 'P1-FIX-7800-DSP-MON',
597
        'currency': 'JPY',
598
        'netRevenue': true,
599
        'ttl': 3000,
600
        'referrer': '',
601
        'meta': {
602
          'advertiserDomains': [
603
            'www.example.com'
604
          ]
605
        },
606
        'mediaType': 'banner',
607
        'ad': '<!-- adtag -->'
608
      }];
609
      const result = spec.interpretResponse(serverResponseBanner, bidRequestBanner[0]);
1✔
610
      expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
1✔
611
      expect(result[0].requestId).to.equal(expectedResponse[0].requestId);
1✔
612
      expect(result[0].cpm).to.equal(expectedResponse[0].cpm);
1✔
613
      expect(result[0].width).to.equal(expectedResponse[0].width);
1✔
614
      expect(result[0].height).to.equal(expectedResponse[0].height);
1✔
615
      expect(result[0].creativeId).to.equal(expectedResponse[0].creativeId);
1✔
616
      expect(result[0].dealId).to.equal(expectedResponse[0].dealId);
1✔
617
      expect(result[0].currency).to.equal(expectedResponse[0].currency);
1✔
618
      expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType);
1✔
619
      expect(result[0].ad).to.equal(expectedResponse[0].ad);
1✔
620
      expect(result[0].meta.advertiserDomains[0]).to.equal(expectedResponse[0].meta.advertiserDomains[0]);
1✔
621
    });
622

623
    const serverResponseVideo = {
1✔
624
      body: {
625
        'uid': '23beaa6af6cdde',
626
        'height': 360,
627
        'width': 640,
628
        'cpm': 0.0536616,
629
        'dealId': 'P1-FIX-7800-DSP-MON',
630
        'crid': '2494768',
631
        'currency': 'JPY',
632
        'statusMessage': 'Bid available',
633
        'adm': '<!-- vast -->'
634
      }
635
    };
636

637
    const bidRequestVideo = [
1✔
638
      {
639
        'method': 'GET',
640
        'url': 'https://y.one.impact-ad.jp/h_bid',
641
        'data': {
642
          'v': 'hb1',
643
          'p': '41993',
644
          'w': '640',
645
          'h': '360',
646
          'cb': 12892917383,
647
          'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836',
648
          'uid': '23beaa6af6cdde',
649
          't': 'i',
650
          'language': 'ja',
651
          'screen_size': '1440x900'
652
        }
653
      }
654
    ];
655

656
    it('should get the correct bid response for video', function () {
1✔
657
      const expectedResponse = [{
1✔
658
        'requestId': '23beaa6af6cdde',
659
        'cpm': 53.6616,
660
        'width': 640,
661
        'height': 360,
662
        'creativeId': '2494768',
663
        'dealId': 'P1-FIX-7800-DSP-MON',
664
        'currency': 'JPY',
665
        'netRevenue': true,
666
        'ttl': 3000,
667
        'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836',
668
        'meta': {
669
          'advertiserDomains': []
670
        },
671
        'mediaType': 'video',
672
        'vastXml': '<!-- vast -->',
673
        'renderer': {
674
          id: '23beaa6af6cdde',
675
          url: VIDEO_PLAYER_URL
676
        }
677
      }];
678
      const result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]);
1✔
679
      expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
1✔
680
      expect(result[0].requestId).to.equal(expectedResponse[0].requestId);
1✔
681
      expect(result[0].cpm).to.equal(expectedResponse[0].cpm);
1✔
682
      expect(result[0].width).to.equal(expectedResponse[0].width);
1✔
683
      expect(result[0].height).to.equal(expectedResponse[0].height);
1✔
684
      expect(result[0].creativeId).to.equal(expectedResponse[0].creativeId);
1✔
685
      expect(result[0].dealId).to.equal(expectedResponse[0].dealId);
1✔
686
      expect(result[0].currency).to.equal(expectedResponse[0].currency);
1✔
687
      expect(result[0].vastXml).to.equal(expectedResponse[0].vastXml);
1✔
688
      expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType);
1✔
689
      expect(result[0].referrer).to.equal(expectedResponse[0].referrer);
1✔
690
      expect(result[0].renderer.id).to.equal(expectedResponse[0].renderer.id);
1✔
691
      expect(result[0].renderer.url).to.equal(expectedResponse[0].renderer.url);
1✔
692
      expect(result[0].meta.advertiserDomains[0]).to.equal(expectedResponse[0].meta.advertiserDomains[0]);
1✔
693
    });
694

695
    it('handles empty bid response', function () {
1✔
696
      const response = {
1✔
697
        body: {
698
          'uid': '2c0b634db95a01',
699
          'height': 0,
700
          'crid': '',
701
          'statusMessage': 'Bid returned empty or error response',
702
          'width': 0,
703
          'cpm': 0
704
        }
705
      };
706
      const result = spec.interpretResponse(response, bidRequestBanner[0]);
1✔
707
      expect(result.length).to.equal(0);
1✔
708
    });
709
  });
710

711
  describe('getUserSyncs', function () {
1✔
712
    it('handles empty sync options', function () {
1✔
713
      expect(spec.getUserSyncs({})).to.be.undefined;
1✔
714
    });
715

716
    it('should return a sync url if iframe syncs are enabled and UserAgent is not Safari or iOS', function () {
1✔
717
      const result = spec.getUserSyncs({
1✔
718
        'iframeEnabled': true
719
      });
720

721
      if (getBrowser() === browserTypes.SAFARI || getOS() === osTypes.IOS) {
1!
722
        expect(result).to.be.undefined;
1✔
723
      } else {
UNCOV
724
        expect(result).to.deep.equal([{
×
725
          type: 'iframe', url: USER_SYNC_URL
726
        }]);
727
      }
728
    });
729

730
    it('should skip sync request in case GDPR applies', function () {
1✔
731
      expect(spec.getUserSyncs({'iframeEnabled': true}, [], {
1✔
732
        consentString: 'GDPR_CONSENT_STRING',
733
        gdprApplies: true,
734
      })).to.be.undefined;
735
    });
736
  });
737
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc