@@ -79,6 +79,22 @@ const bidRequestBanner = {
79
79
}
80
80
}
81
81
82
+ const bidRequestBannerMultiSizes = {
83
+ ...bidRequestCommonParams ,
84
+ ...{
85
+ 'mediaTypes' : {
86
+ 'banner' : {
87
+ 'sizes' : [ [ 640 , 360 ] , [ 480 , 320 ] ]
88
+ }
89
+ }
90
+ }
91
+ }
92
+
93
+ const bidRequestVideoAndBanner = {
94
+ ...bidRequestBanner ,
95
+ ...bidRequestVideo
96
+ }
97
+
82
98
describe ( 'shBidAdapter' , function ( ) {
83
99
const adapter = newBidder ( spec )
84
100
@@ -120,8 +136,8 @@ describe('shBidAdapter', function () {
120
136
} ] , bidderRequest )
121
137
const payload = request . data . requests [ 0 ] ;
122
138
expect ( payload ) . to . be . an ( 'object' ) ;
123
- expect ( payload . video ) . to . have . property ( 'width' , 640 ) ;
124
- expect ( payload . video ) . to . have . property ( 'height' , 480 ) ;
139
+ expect ( payload . size ) . to . have . property ( 'width' , 640 ) ;
140
+ expect ( payload . size ) . to . have . property ( 'height' , 480 ) ;
125
141
126
142
const request2 = spec . buildRequests ( [ {
127
143
'params' : { } ,
@@ -130,8 +146,8 @@ describe('shBidAdapter', function () {
130
146
} ] , bidderRequest )
131
147
const payload2 = request2 . data . requests [ 0 ] ;
132
148
expect ( payload ) . to . be . an ( 'object' ) ;
133
- expect ( payload2 . video ) . to . have . property ( 'width' , 320 ) ;
134
- expect ( payload2 . video ) . to . have . property ( 'height' , 240 ) ;
149
+ expect ( payload2 . size ) . to . have . property ( 'width' , 320 ) ;
150
+ expect ( payload2 . size ) . to . have . property ( 'height' , 240 ) ;
135
151
} )
136
152
137
153
it ( 'should get size from mediaTypes when sizes property is empty' , function ( ) {
@@ -146,8 +162,8 @@ describe('shBidAdapter', function () {
146
162
} ] , bidderRequest )
147
163
const payload = request . data . requests [ 0 ] ;
148
164
expect ( payload ) . to . be . an ( 'object' ) ;
149
- expect ( payload . video ) . to . have . property ( 'width' , 640 ) ;
150
- expect ( payload . video ) . to . have . property ( 'height' , 480 ) ;
165
+ expect ( payload . size ) . to . have . property ( 'width' , 640 ) ;
166
+ expect ( payload . size ) . to . have . property ( 'height' , 480 ) ;
151
167
152
168
const request2 = spec . buildRequests ( [ {
153
169
'params' : { } ,
@@ -160,8 +176,8 @@ describe('shBidAdapter', function () {
160
176
} ] , bidderRequest )
161
177
const payload2 = request2 . data . requests [ 0 ] ;
162
178
expect ( payload ) . to . be . an ( 'object' ) ;
163
- expect ( payload2 . video ) . to . have . property ( 'width' , 320 ) ;
164
- expect ( payload2 . video ) . to . have . property ( 'height' , 240 ) ;
179
+ expect ( payload2 . size ) . to . have . property ( 'width' , 320 ) ;
180
+ expect ( payload2 . size ) . to . have . property ( 'height' , 240 ) ;
165
181
} )
166
182
167
183
it ( 'should attach valid params to the payload when type is video' , function ( ) {
@@ -191,6 +207,38 @@ describe('shBidAdapter', function () {
191
207
expect ( payload ) . to . have . property ( 'type' , 5 ) ;
192
208
} )
193
209
210
+ it ( 'should attach valid params to the payload when type is banner (multi sizes)' , function ( ) {
211
+ const request = spec . buildRequests ( [ bidRequestBannerMultiSizes ] , bidderRequest )
212
+ const payload = request . data . requests [ 0 ] ;
213
+ expect ( payload ) . to . be . an ( 'object' ) ;
214
+ expect ( payload ) . to . have . property ( 'playerId' , '47427aa0-f11a-4d24-abca-1295a46a46cd' ) ;
215
+ expect ( payload ) . to . have . property ( 'mediaType' , BANNER ) ;
216
+ expect ( payload ) . to . have . property ( 'type' , 5 ) ;
217
+ expect ( payload ) . to . have . nested . property ( 'size.width' , 640 ) ;
218
+ expect ( payload ) . to . have . nested . property ( 'size.height' , 360 ) ;
219
+ const payload2 = request . data . requests [ 1 ] ;
220
+ expect ( payload2 ) . to . be . an ( 'object' ) ;
221
+ expect ( payload2 ) . to . have . property ( 'playerId' , '47427aa0-f11a-4d24-abca-1295a46a46cd' ) ;
222
+ expect ( payload2 ) . to . have . property ( 'mediaType' , BANNER ) ;
223
+ expect ( payload2 ) . to . have . property ( 'type' , 5 ) ;
224
+ expect ( payload2 ) . to . have . nested . property ( 'size.width' , 480 ) ;
225
+ expect ( payload2 ) . to . have . nested . property ( 'size.height' , 320 ) ;
226
+ } )
227
+
228
+ it ( 'should attach valid params to the payload when type is banner and video' , function ( ) {
229
+ const request = spec . buildRequests ( [ bidRequestVideoAndBanner ] , bidderRequest )
230
+ const payload = request . data . requests [ 0 ] ;
231
+ expect ( payload ) . to . be . an ( 'object' ) ;
232
+ expect ( payload ) . to . have . property ( 'playerId' , '47427aa0-f11a-4d24-abca-1295a46a46cd' ) ;
233
+ expect ( payload ) . to . have . property ( 'mediaType' , VIDEO ) ;
234
+ expect ( payload ) . to . have . property ( 'type' , 2 ) ;
235
+ const payload2 = request . data . requests [ 1 ] ;
236
+ expect ( payload2 ) . to . be . an ( 'object' ) ;
237
+ expect ( payload2 ) . to . have . property ( 'playerId' , '47427aa0-f11a-4d24-abca-1295a46a46cd' ) ;
238
+ expect ( payload2 ) . to . have . property ( 'mediaType' , BANNER ) ;
239
+ expect ( payload2 ) . to . have . property ( 'type' , 5 ) ;
240
+ } )
241
+
194
242
it ( 'passes gdpr if present' , function ( ) {
195
243
const request = spec . buildRequests ( [ bidRequestVideo ] , { ...bidderRequest , ...gdpr } )
196
244
const payload = request . data . requests [ 0 ] ;
@@ -208,16 +256,36 @@ describe('shBidAdapter', function () {
208
256
const vastTag = 'https://video-library.stage.showheroes.com/commercial/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6'
209
257
const vastXml = '<?xml version="1.0" encoding="utf-8"?><VAST version="3.0"><Error><![CDATA[https://static.showheroes.com/shim.gif]]></Error></VAST>'
210
258
211
- const response = {
259
+ const basicResponse = {
260
+ 'cpm' : 5 ,
261
+ 'currency' : 'EUR' ,
262
+ 'mediaType' : VIDEO ,
263
+ 'context' : 'instream' ,
264
+ 'bidId' : '38b373e1e31c18' ,
265
+ 'size' : { 'width' : 640 , 'height' : 480 } ,
266
+ 'vastTag' : 'https:\/\/video-library.stage.showheroes.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6' ,
267
+ 'vastXml' : vastXml ,
268
+ } ;
269
+
270
+ const responseVideo = {
212
271
'bids' : [ {
213
- 'cpm' : 5 ,
214
- 'currency' : 'EUR' ,
215
- 'bidId' : '38b373e1e31c18' ,
216
- 'video' : { 'width' : 640 , 'height' : 480 } ,
217
- 'vastTag' : 'https:\/\/video-library.stage.showheroes.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6' ,
218
- 'vastXml' : vastXml ,
272
+ ...basicResponse ,
219
273
} ] ,
220
- }
274
+ } ;
275
+
276
+ const responseVideoOutstream = {
277
+ 'bids' : [ {
278
+ ...basicResponse ,
279
+ 'context' : 'outstream' ,
280
+ } ] ,
281
+ } ;
282
+
283
+ const responseBanner = {
284
+ 'bids' : [ {
285
+ ...basicResponse ,
286
+ 'mediaType' : BANNER ,
287
+ } ] ,
288
+ } ;
221
289
222
290
it ( 'should get correct bid response when type is video' , function ( ) {
223
291
const request = spec . buildRequests ( [ bidRequestVideo ] , bidderRequest )
@@ -240,14 +308,14 @@ describe('shBidAdapter', function () {
240
308
}
241
309
]
242
310
243
- const result = spec . interpretResponse ( { 'body' : response } , request )
311
+ const result = spec . interpretResponse ( { 'body' : responseVideo } , request )
244
312
expect ( result ) . to . deep . equal ( expectedResponse )
245
313
} )
246
314
247
315
it ( 'should get correct bid response when type is banner' , function ( ) {
248
316
const request = spec . buildRequests ( [ bidRequestBanner ] , bidderRequest )
249
317
250
- const result = spec . interpretResponse ( { 'body' : response } , request )
318
+ const result = spec . interpretResponse ( { 'body' : responseBanner } , request )
251
319
expect ( result [ 0 ] ) . to . have . property ( 'mediaType' , BANNER ) ;
252
320
expect ( result [ 0 ] . ad ) . to . include ( '<script async src="https://static.showheroes.com/publishertag.js' )
253
321
expect ( result [ 0 ] . ad ) . to . include ( '<div class="showheroes-spot"' )
@@ -266,7 +334,7 @@ describe('shBidAdapter', function () {
266
334
267
335
const request = spec . buildRequests ( [ bidRequest ] , bidderRequest )
268
336
269
- const result = spec . interpretResponse ( { 'body' : response } , request )
337
+ const result = spec . interpretResponse ( { 'body' : responseVideoOutstream } , request )
270
338
const bid = result [ 0 ]
271
339
expect ( bid ) . to . have . property ( 'mediaType' , VIDEO ) ;
272
340
@@ -297,7 +365,7 @@ describe('shBidAdapter', function () {
297
365
298
366
const request = spec . buildRequests ( [ bidRequest ] , bidderRequest )
299
367
300
- const result = spec . interpretResponse ( { 'body' : response } , request )
368
+ const result = spec . interpretResponse ( { 'body' : responseVideoOutstream } , request )
301
369
const bid = result [ 0 ]
302
370
expect ( bid ) . to . have . property ( 'mediaType' , VIDEO ) ;
303
371
@@ -332,7 +400,7 @@ describe('shBidAdapter', function () {
332
400
333
401
const request = spec . buildRequests ( [ bidRequest ] , bidderRequest )
334
402
335
- const result = spec . interpretResponse ( { 'body' : response } , request )
403
+ const result = spec . interpretResponse ( { 'body' : responseVideoOutstream } , request )
336
404
const bid = result [ 0 ]
337
405
expect ( bid ) . to . have . property ( 'mediaType' , VIDEO ) ;
338
406
0 commit comments