@@ -2,6 +2,7 @@ import { expect } from 'chai';
2
2
import {
3
3
spec ,
4
4
BANNER_ENDPOINT ,
5
+ buildExtuidQuery ,
5
6
} from 'modules/ssp_genieeBidAdapter.js' ;
6
7
import { config } from 'src/config.js' ;
7
8
@@ -347,15 +348,103 @@ describe('ssp_genieeBidAdapter', function () {
347
348
expect ( request [ 0 ] . data . apid ) . to . deep . equal ( bundle ) ;
348
349
} ) ;
349
350
350
- it ( 'should not include the extuid query when bid.userId.imuid does not exist' , function ( ) {
351
+ it ( 'should include only imuid in extuid query when only imuid exists' , function ( ) {
352
+ const imuid = 'b.a4ad1d3eeb51e600' ;
353
+ const request = spec . buildRequests ( [ { ...BANNER_BID , userId : { imuid} } ] ) ;
354
+ expect ( request [ 0 ] . data . extuid ) . to . deep . equal ( `im:${ imuid } ` ) ;
355
+ } ) ;
356
+
357
+ it ( 'should include only id5id in extuid query when only id5id exists' , function ( ) {
358
+ const id5id = 'id5id' ;
359
+ const request = spec . buildRequests ( [ { ...BANNER_BID , userId : { id5id : { uid : id5id } } } ] ) ;
360
+ expect ( request [ 0 ] . data . extuid ) . to . deep . equal ( `id5:${ id5id } ` ) ;
361
+ } ) ;
362
+
363
+ it ( 'should include id5id and imuid in extuid query when id5id and imuid exists' , function ( ) {
364
+ const imuid = 'b.a4ad1d3eeb51e600' ;
365
+ const id5id = 'id5id' ;
366
+ const request = spec . buildRequests ( [ { ...BANNER_BID , userId : { id5id : { uid : id5id } , imuid : imuid } } ] ) ;
367
+ expect ( request [ 0 ] . data . extuid ) . to . deep . equal ( `id5:${ id5id } \tim:${ imuid } ` ) ;
368
+ } ) ;
369
+
370
+ it ( 'should not include the extuid query when both id5 and imuid are missing' , function ( ) {
351
371
const request = spec . buildRequests ( [ BANNER_BID ] ) ;
352
372
expect ( request [ 0 ] . data ) . to . not . have . property ( 'extuid' ) ;
353
373
} ) ;
354
374
355
- it ( 'should include an extuid query when bid.userId.imuid exists' , function ( ) {
356
- const imuid = 'b.a4ad1d3eeb51e600' ;
357
- const request = spec . buildRequests ( [ { ...BANNER_BID , userId : { imuid} } ] ) ;
358
- expect ( request [ 0 ] . data . extuid ) . to . deep . equal ( `im:${ imuid } ` ) ;
375
+ describe ( 'buildExtuidQuery' , function ( ) {
376
+ it ( 'should return tab-separated string when both id5 and imuId exist' , function ( ) {
377
+ const result = buildExtuidQuery ( { id5 : 'test_id5' , imuId : 'test_imu' } ) ;
378
+ expect ( result ) . to . equal ( 'id5:test_id5\tim:test_imu' ) ;
379
+ } ) ;
380
+
381
+ it ( 'should return only id5 when imuId is missing' , function ( ) {
382
+ const result = buildExtuidQuery ( { id5 : 'test_id5' , imuId : null } ) ;
383
+ expect ( result ) . to . equal ( 'id5:test_id5' ) ;
384
+ } ) ;
385
+
386
+ it ( 'should return only imuId when id5 is missing' , function ( ) {
387
+ const result = buildExtuidQuery ( { id5 : null , imuId : 'test_imu' } ) ;
388
+ expect ( result ) . to . equal ( 'im:test_imu' ) ;
389
+ } ) ;
390
+
391
+ it ( 'should return null when both id5 and imuId are missing' , function ( ) {
392
+ const result = buildExtuidQuery ( { id5 : null , imuId : null } ) ;
393
+ expect ( result ) . to . be . null ;
394
+ } ) ;
395
+ } ) ;
396
+
397
+ it ( 'should include gpid when ortb2Imp.ext.gpid exists' , function ( ) {
398
+ const gpid = '/123/abc' ;
399
+ const bidWithGpid = {
400
+ ...BANNER_BID ,
401
+ ortb2Imp : {
402
+ ext : {
403
+ gpid : gpid
404
+ }
405
+ }
406
+ } ;
407
+ const request = spec . buildRequests ( [ bidWithGpid ] ) ;
408
+ expect ( String ( request [ 0 ] . data . gpid ) ) . to . have . string ( gpid ) ;
409
+ } ) ;
410
+
411
+ it ( 'should include gpid when ortb2Imp.ext.data.pbadslot exists' , function ( ) {
412
+ const pbadslot = '/123/abc' ;
413
+ const bidWithPbadslot = {
414
+ ...BANNER_BID ,
415
+ ortb2Imp : {
416
+ ext : {
417
+ data : {
418
+ pbadslot : pbadslot
419
+ }
420
+ }
421
+ }
422
+ } ;
423
+ const request = spec . buildRequests ( [ bidWithPbadslot ] ) ;
424
+ expect ( String ( request [ 0 ] . data . gpid ) ) . to . have . string ( pbadslot ) ;
425
+ } ) ;
426
+
427
+ it ( 'should prioritize ortb2Imp.ext.gpid over ortb2Imp.ext.data.pbadslot' , function ( ) {
428
+ const gpid = '/123/abc' ;
429
+ const pbadslot = '/456/def' ;
430
+ const bidWithBoth = {
431
+ ...BANNER_BID ,
432
+ ortb2Imp : {
433
+ ext : {
434
+ gpid : gpid ,
435
+ data : {
436
+ pbadslot : pbadslot
437
+ }
438
+ }
439
+ }
440
+ } ;
441
+ const request = spec . buildRequests ( [ bidWithBoth ] ) ;
442
+ expect ( String ( request [ 0 ] . data . gpid ) ) . to . have . string ( gpid ) ;
443
+ } ) ;
444
+
445
+ it ( 'should not include gpid when neither ortb2Imp.ext.gpid nor ortb2Imp.ext.data.pbadslot exists' , function ( ) {
446
+ const request = spec . buildRequests ( [ BANNER_BID ] ) ;
447
+ expect ( request [ 0 ] . data ) . to . not . have . property ( 'gpid' ) ;
359
448
} ) ;
360
449
361
450
it ( 'should include gpid when ortb2Imp.ext.gpid exists' , function ( ) {
0 commit comments