@@ -226,6 +226,15 @@ describe('OguryBidAdapter', function () {
226
226
} ) ;
227
227
228
228
describe ( 'buildRequests' , function ( ) {
229
+ const stubbedWidth = 200
230
+ const stubbedHeight = 600
231
+ const stubbedWidthMethod = sinon . stub ( window . top . document . documentElement , 'clientWidth' ) . get ( function ( ) {
232
+ return stubbedWidth ;
233
+ } ) ;
234
+ const stubbedHeightMethod = sinon . stub ( window . top . document . documentElement , 'clientHeight' ) . get ( function ( ) {
235
+ return stubbedHeight ;
236
+ } ) ;
237
+
229
238
const defaultTimeout = 1000 ;
230
239
const expectedRequestObject = {
231
240
id : bidRequests [ 0 ] . auctionId ,
@@ -270,10 +279,19 @@ describe('OguryBidAdapter', function () {
270
279
} ,
271
280
ext : {
272
281
prebidversion : '$prebid.version$' ,
273
- adapterversion : '1.2.11'
282
+ adapterversion : '1.2.12'
283
+ } ,
284
+ device : {
285
+ w : stubbedWidth ,
286
+ h : stubbedHeight
274
287
}
275
288
} ;
276
289
290
+ after ( function ( ) {
291
+ stubbedWidthMethod . restore ( ) ;
292
+ stubbedHeightMethod . restore ( ) ;
293
+ } ) ;
294
+
277
295
it ( 'sends bid request to ENDPOINT via POST' , function ( ) {
278
296
const validBidRequests = utils . deepClone ( bidRequests )
279
297
@@ -290,6 +308,166 @@ describe('OguryBidAdapter', function () {
290
308
expect ( request . data . regs . ext . gdpr ) . to . be . a ( 'number' ) ;
291
309
} ) ;
292
310
311
+ describe ( 'getClientWidth' , ( ) => {
312
+ function testGetClientWidth ( testGetClientSizeParams ) {
313
+ const stubbedClientWidth = sinon . stub ( window . top . document . documentElement , 'clientWidth' ) . get ( function ( ) {
314
+ return testGetClientSizeParams . docClientSize
315
+ } )
316
+
317
+ const stubbedInnerWidth = sinon . stub ( window . top , 'innerWidth' ) . get ( function ( ) {
318
+ return testGetClientSizeParams . innerSize
319
+ } )
320
+
321
+ const stubbedOuterWidth = sinon . stub ( window . top , 'outerWidth' ) . get ( function ( ) {
322
+ return testGetClientSizeParams . outerSize
323
+ } )
324
+
325
+ const stubbedWidth = sinon . stub ( window . top . screen , 'width' ) . get ( function ( ) {
326
+ return testGetClientSizeParams . screenSize
327
+ } )
328
+
329
+ const validBidRequests = utils . deepClone ( bidRequests )
330
+
331
+ const request = spec . buildRequests ( validBidRequests , bidderRequest ) ;
332
+ expect ( request . data . device . w ) . to . equal ( testGetClientSizeParams . expectedSize ) ;
333
+
334
+ stubbedClientWidth . restore ( ) ;
335
+ stubbedInnerWidth . restore ( ) ;
336
+ stubbedOuterWidth . restore ( ) ;
337
+ stubbedWidth . restore ( ) ;
338
+ }
339
+
340
+ it ( 'should get documentElementClientWidth by default' , ( ) => {
341
+ testGetClientWidth ( {
342
+ docClientSize : 22 ,
343
+ innerSize : 50 ,
344
+ outerSize : 45 ,
345
+ screenSize : 10 ,
346
+ expectedSize : 22 ,
347
+ } )
348
+ } )
349
+
350
+ it ( 'should get innerWidth as first fallback' , ( ) => {
351
+ testGetClientWidth ( {
352
+ docClientSize : undefined ,
353
+ innerSize : 700 ,
354
+ outerSize : 650 ,
355
+ screenSize : 10 ,
356
+ expectedSize : 700 ,
357
+ } )
358
+ } )
359
+
360
+ it ( 'should get outerWidth as second fallback' , ( ) => {
361
+ testGetClientWidth ( {
362
+ docClientSize : undefined ,
363
+ innerSize : undefined ,
364
+ outerSize : 650 ,
365
+ screenSize : 10 ,
366
+ expectedSize : 650 ,
367
+ } )
368
+ } )
369
+
370
+ it ( 'should get screenWidth as last fallback' , ( ) => {
371
+ testGetClientWidth ( {
372
+ docClientSize : undefined ,
373
+ innerSize : undefined ,
374
+ outerSize : undefined ,
375
+ screenSize : 10 ,
376
+ expectedSize : 10 ,
377
+ } ) ;
378
+ } ) ;
379
+
380
+ it ( 'should return 0 if all window width values are undefined' , ( ) => {
381
+ testGetClientWidth ( {
382
+ docClientSize : undefined ,
383
+ innerSize : undefined ,
384
+ outerSize : undefined ,
385
+ screenSize : undefined ,
386
+ expectedSize : 0 ,
387
+ } ) ;
388
+ } ) ;
389
+ } ) ;
390
+
391
+ describe ( 'getClientHeight' , ( ) => {
392
+ function testGetClientHeight ( testGetClientSizeParams ) {
393
+ const stubbedClientHeight = sinon . stub ( window . top . document . documentElement , 'clientHeight' ) . get ( function ( ) {
394
+ return testGetClientSizeParams . docClientSize
395
+ } )
396
+
397
+ const stubbedInnerHeight = sinon . stub ( window . top , 'innerHeight' ) . get ( function ( ) {
398
+ return testGetClientSizeParams . innerSize
399
+ } )
400
+
401
+ const stubbedOuterHeight = sinon . stub ( window . top , 'outerHeight' ) . get ( function ( ) {
402
+ return testGetClientSizeParams . outerSize
403
+ } )
404
+
405
+ const stubbedHeight = sinon . stub ( window . top . screen , 'height' ) . get ( function ( ) {
406
+ return testGetClientSizeParams . screenSize
407
+ } )
408
+
409
+ const validBidRequests = utils . deepClone ( bidRequests )
410
+
411
+ const request = spec . buildRequests ( validBidRequests , bidderRequest ) ;
412
+ expect ( request . data . device . h ) . to . equal ( testGetClientSizeParams . expectedSize ) ;
413
+
414
+ stubbedClientHeight . restore ( ) ;
415
+ stubbedInnerHeight . restore ( ) ;
416
+ stubbedOuterHeight . restore ( ) ;
417
+ stubbedHeight . restore ( ) ;
418
+ }
419
+
420
+ it ( 'should get documentElementClientHeight by default' , ( ) => {
421
+ testGetClientHeight ( {
422
+ docClientSize : 420 ,
423
+ innerSize : 500 ,
424
+ outerSize : 480 ,
425
+ screenSize : 230 ,
426
+ expectedSize : 420 ,
427
+ } ) ;
428
+ } ) ;
429
+
430
+ it ( 'should get innerHeight as first fallback' , ( ) => {
431
+ testGetClientHeight ( {
432
+ docClientSize : undefined ,
433
+ innerSize : 500 ,
434
+ outerSize : 480 ,
435
+ screenSize : 230 ,
436
+ expectedSize : 500 ,
437
+ } ) ;
438
+ } ) ;
439
+
440
+ it ( 'should get outerHeight as second fallback' , ( ) => {
441
+ testGetClientHeight ( {
442
+ docClientSize : undefined ,
443
+ innerSize : undefined ,
444
+ outerSize : 480 ,
445
+ screenSize : 230 ,
446
+ expectedSize : 480 ,
447
+ } ) ;
448
+ } ) ;
449
+
450
+ it ( 'should get screenHeight as last fallback' , ( ) => {
451
+ testGetClientHeight ( {
452
+ docClientSize : undefined ,
453
+ innerSize : undefined ,
454
+ outerSize : undefined ,
455
+ screenSize : 230 ,
456
+ expectedSize : 230 ,
457
+ } ) ;
458
+ } ) ;
459
+
460
+ it ( 'should return 0 if all window height values are undefined' , ( ) => {
461
+ testGetClientHeight ( {
462
+ docClientSize : undefined ,
463
+ innerSize : undefined ,
464
+ outerSize : undefined ,
465
+ screenSize : undefined ,
466
+ expectedSize : 0 ,
467
+ } ) ;
468
+ } ) ;
469
+ } ) ;
470
+
293
471
it ( 'should not add gdpr infos if not present' , ( ) => {
294
472
const bidderRequestWithoutGdpr = {
295
473
...bidderRequest ,
@@ -481,7 +659,7 @@ describe('OguryBidAdapter', function () {
481
659
advertiserDomains : openRtbBidResponse . body . seatbid [ 0 ] . bid [ 0 ] . adomain
482
660
} ,
483
661
nurl : openRtbBidResponse . body . seatbid [ 0 ] . bid [ 0 ] . nurl ,
484
- adapterVersion : '1.2.11 ' ,
662
+ adapterVersion : '1.2.12 ' ,
485
663
prebidVersion : '$prebid.version$'
486
664
} , {
487
665
requestId : openRtbBidResponse . body . seatbid [ 0 ] . bid [ 1 ] . impid ,
@@ -498,7 +676,7 @@ describe('OguryBidAdapter', function () {
498
676
advertiserDomains : openRtbBidResponse . body . seatbid [ 0 ] . bid [ 1 ] . adomain
499
677
} ,
500
678
nurl : openRtbBidResponse . body . seatbid [ 0 ] . bid [ 1 ] . nurl ,
501
- adapterVersion : '1.2.11 ' ,
679
+ adapterVersion : '1.2.12 ' ,
502
680
prebidVersion : '$prebid.version$'
503
681
} ]
504
682
0 commit comments