@@ -4,6 +4,9 @@ import parse from 'url-parse';
4
4
import buildDfpVideoUrl from 'modules/dfpAdServerVideo' ;
5
5
import { parseQS } from 'src/url' ;
6
6
import adUnit from 'test/fixtures/video/adUnit' ;
7
+ import * as utils from 'src/utils' ;
8
+ import { config } from 'src/config' ;
9
+ import { targeting } from 'src/targeting' ;
7
10
8
11
const bid = {
9
12
videoCacheKey : 'abc' ,
@@ -107,6 +110,79 @@ describe('The DFP video support module', () => {
107
110
expect ( customParams ) . to . have . property ( 'hb_cache_id' , bid . videoCacheKey ) ;
108
111
} ) ;
109
112
113
+ describe ( 'special targeting unit test' , ( ) => {
114
+ const allTargetingData = {
115
+ 'hb_format' : 'video' ,
116
+ 'hb_source' : 'client' ,
117
+ 'hb_size' : '640x480' ,
118
+ 'hb_pb' : '5.00' ,
119
+ 'hb_adid' : '2c4f6cc3ba128a' ,
120
+ 'hb_bidder' : 'testBidder2' ,
121
+ 'hb_format_testBidder2' : 'video' ,
122
+ 'hb_source_testBidder2' : 'client' ,
123
+ 'hb_size_testBidder2' : '640x480' ,
124
+ 'hb_pb_testBidder2' : '5.00' ,
125
+ 'hb_adid_testBidder2' : '2c4f6cc3ba128a' ,
126
+ 'hb_bidder_testBidder2' : 'testBidder2' ,
127
+ 'hb_format_appnexus' : 'video' ,
128
+ 'hb_source_appnexus' : 'client' ,
129
+ 'hb_size_appnexus' : '640x480' ,
130
+ 'hb_pb_appnexus' : '5.00' ,
131
+ 'hb_adid_appnexus' : '44e0b5f2e5cace' ,
132
+ 'hb_bidder_appnexus' : 'appnexus'
133
+ } ;
134
+ let targetingStub ;
135
+
136
+ before ( ( ) => {
137
+ targetingStub = sinon . stub ( targeting , 'getAllTargeting' ) ;
138
+ targetingStub . returns ( { 'video1' : allTargetingData } ) ;
139
+
140
+ config . setConfig ( {
141
+ enableSendAllBids : true
142
+ } ) ;
143
+ } ) ;
144
+
145
+ after ( ( ) => {
146
+ config . resetConfig ( ) ;
147
+ targetingStub . restore ( ) ;
148
+ } ) ;
149
+
150
+ it ( 'should include all adserver targeting in cust_params if pbjs.enableSendAllBids is true' , ( ) => {
151
+ const adUnitsCopy = utils . deepClone ( adUnit ) ;
152
+ adUnitsCopy . bids . push ( {
153
+ 'bidder' : 'testBidder2' ,
154
+ 'params' : {
155
+ 'placementId' : '9333431' ,
156
+ 'video' : {
157
+ 'skipppable' : false ,
158
+ 'playback_methods' : [ 'auto_play_sound_off' ]
159
+ }
160
+ }
161
+ } ) ;
162
+
163
+ const bidCopy = Object . assign ( { } , bid ) ;
164
+ bidCopy . adserverTargeting = {
165
+ hb_adid : 'ad_id' ,
166
+ } ;
167
+
168
+ const url = parse ( buildDfpVideoUrl ( {
169
+ adUnit : adUnitsCopy ,
170
+ bid : bidCopy ,
171
+ params : {
172
+ 'iu' : 'my/adUnit'
173
+ }
174
+ } ) ) ;
175
+ const queryObject = parseQS ( url . query ) ;
176
+ const customParams = parseQS ( '?' + decodeURIComponent ( queryObject . cust_params ) ) ;
177
+
178
+ expect ( customParams ) . to . have . property ( 'hb_adid' , 'ad_id' ) ;
179
+ expect ( customParams ) . to . have . property ( 'hb_uuid' , bid . videoCacheKey ) ;
180
+ expect ( customParams ) . to . have . property ( 'hb_cache_id' , bid . videoCacheKey ) ;
181
+ expect ( customParams ) . to . have . property ( 'hb_bidder_appnexus' , 'appnexus' ) ;
182
+ expect ( customParams ) . to . have . property ( 'hb_bidder_testBidder2' , 'testBidder2' ) ;
183
+ } ) ;
184
+ } ) ;
185
+
110
186
it ( 'should merge the user-provided cust_params with the default ones' , ( ) => {
111
187
const bidCopy = Object . assign ( { } , bid ) ;
112
188
bidCopy . adserverTargeting = {
0 commit comments