@@ -7,6 +7,7 @@ import * as utils from 'src/utils.js';
7
7
import { config } from 'src/config.js' ;
8
8
import { targeting } from 'src/targeting.js' ;
9
9
import { auctionManager } from 'src/auctionManager.js' ;
10
+ import { uspDataHandler } from 'src/adapterManager.js' ;
10
11
import * as adpod from 'modules/adpod.js' ;
11
12
import { server } from 'test/mocks/xhr.js' ;
12
13
@@ -115,6 +116,44 @@ describe('The DFP video support module', function () {
115
116
expect ( customParams ) . to . have . property ( 'hb_cache_id' , bid . videoCacheKey ) ;
116
117
} ) ;
117
118
119
+ it ( 'should include the us_privacy key when USP Consent is available' , function ( ) {
120
+ let uspDataHandlerStub = sinon . stub ( uspDataHandler , 'getConsentData' ) ;
121
+ uspDataHandlerStub . returns ( '1YYY' ) ;
122
+
123
+ const bidCopy = utils . deepClone ( bid ) ;
124
+ bidCopy . adserverTargeting = Object . assign ( bidCopy . adserverTargeting , {
125
+ hb_adid : 'ad_id' ,
126
+ } ) ;
127
+
128
+ const url = parse ( buildDfpVideoUrl ( {
129
+ adUnit : adUnit ,
130
+ bid : bidCopy ,
131
+ params : {
132
+ 'iu' : 'my/adUnit'
133
+ }
134
+ } ) ) ;
135
+ const queryObject = utils . parseQS ( url . query ) ;
136
+ expect ( queryObject . us_privacy ) . to . equal ( '1YYY' ) ;
137
+ uspDataHandlerStub . restore ( ) ;
138
+ } ) ;
139
+
140
+ it ( 'should not include the us_privacy key when USP Consent is not available' , function ( ) {
141
+ const bidCopy = utils . deepClone ( bid ) ;
142
+ bidCopy . adserverTargeting = Object . assign ( bidCopy . adserverTargeting , {
143
+ hb_adid : 'ad_id' ,
144
+ } ) ;
145
+
146
+ const url = parse ( buildDfpVideoUrl ( {
147
+ adUnit : adUnit ,
148
+ bid : bidCopy ,
149
+ params : {
150
+ 'iu' : 'my/adUnit'
151
+ }
152
+ } ) ) ;
153
+ const queryObject = utils . parseQS ( url . query ) ;
154
+ expect ( queryObject . us_privacy ) . to . equal ( undefined ) ;
155
+ } ) ;
156
+
118
157
describe ( 'special targeting unit test' , function ( ) {
119
158
const allTargetingData = {
120
159
'hb_format' : 'video' ,
@@ -350,6 +389,8 @@ describe('The DFP video support module', function () {
350
389
351
390
it ( 'should return masterTag url' , function ( ) {
352
391
amStub . returns ( getBidsReceived ( ) ) ;
392
+ let uspDataHandlerStub = sinon . stub ( uspDataHandler , 'getConsentData' ) ;
393
+ uspDataHandlerStub . returns ( '1YYY' ) ;
353
394
let url ;
354
395
parse ( buildAdpodVideoUrl ( {
355
396
code : 'adUnitCode-1' ,
@@ -380,10 +421,12 @@ describe('The DFP video support module', function () {
380
421
expect ( queryParams ) . to . have . property ( 'unviewed_position_start' , '1' ) ;
381
422
expect ( queryParams ) . to . have . property ( 'url' ) ;
382
423
expect ( queryParams ) . to . have . property ( 'cust_params' ) ;
424
+ expect ( queryParams ) . to . have . property ( 'us_privacy' , '1YYY' ) ;
383
425
384
426
const custParams = utils . parseQS ( decodeURIComponent ( queryParams . cust_params ) ) ;
385
427
expect ( custParams ) . to . have . property ( 'hb_cache_id' , '123' ) ;
386
428
expect ( custParams ) . to . have . property ( 'hb_pb_cat_dur' , '15.00_395_15s,15.00_406_30s,10.00_395_15s' ) ;
429
+ uspDataHandlerStub . restore ( ) ;
387
430
}
388
431
} ) ;
389
432
0 commit comments