@@ -6,14 +6,31 @@ import { newBidder } from 'src/adapters/bidderFactory';
6
6
7
7
describe ( 'Adyoulike Adapter' , function ( ) {
8
8
const canonicalUrl = 'https://canonical.url/?t=%26' ;
9
+ const referrerUrl = 'http://referrer.url/?param=value' ;
9
10
const defaultDC = 'hb-api' ;
11
+ const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' ;
12
+ const bidderRequest = {
13
+ 'auctionId' : '1d1a030790a475' ,
14
+ 'bidderRequestId' : '22edbae2733bf6' ,
15
+ 'timeout' : 3000 ,
16
+ 'gdprConsent' : {
17
+ consentString : consentString ,
18
+ gdprApplies : true
19
+ } ,
20
+ refererInfo : { referer : referrerUrl }
21
+ } ;
10
22
const bidRequestWithEmptyPlacement = [
11
23
{
12
24
'bidId' : 'bid_id_0' ,
13
25
'bidder' : 'adyoulike' ,
14
26
'placementCode' : 'adunit/hb-0' ,
15
27
'params' : { } ,
16
- 'sizes' : '300x250'
28
+ 'sizes' : '300x250' ,
29
+ 'mediaTypes' :
30
+ { 'banner' :
31
+ { 'sizes' : [ '300x250' , '300x600' ]
32
+ }
33
+ }
17
34
}
18
35
] ;
19
36
const bidRequestWithEmptySizes = {
@@ -39,6 +56,11 @@ describe('Adyoulike Adapter', function () {
39
56
'placement' : 'placement_0'
40
57
} ,
41
58
'sizes' : '300x250' ,
59
+ 'mediaTypes' :
60
+ { 'banner' :
61
+ { 'sizes' : [ '300x250' ]
62
+ }
63
+ } ,
42
64
'transactionId' : 'bid_id_0_transaction_id'
43
65
}
44
66
] ;
@@ -53,6 +75,11 @@ describe('Adyoulike Adapter', function () {
53
75
'DC' : 'fra01'
54
76
} ,
55
77
'sizes' : '300x250' ,
78
+ 'mediaTypes' :
79
+ { 'banner' :
80
+ { 'sizes' : [ '300x250' ]
81
+ }
82
+ } ,
56
83
'transactionId' : 'bid_id_0_transaction_id'
57
84
}
58
85
] ;
@@ -66,6 +93,11 @@ describe('Adyoulike Adapter', function () {
66
93
'placement' : 'placement_0'
67
94
} ,
68
95
'sizes' : '300x250' ,
96
+ 'mediaTypes' :
97
+ { 'banner' :
98
+ { 'sizes' : [ '300x250' ]
99
+ }
100
+ } ,
69
101
'transactionId' : 'bid_id_0_transaction_id'
70
102
} ,
71
103
{
@@ -76,6 +108,11 @@ describe('Adyoulike Adapter', function () {
76
108
'placement' : 'placement_1'
77
109
} ,
78
110
'sizes' : [ [ 300 , 600 ] ] ,
111
+ 'mediaTypes' :
112
+ { 'banner' :
113
+ { 'sizes' : [ '300x600' ]
114
+ }
115
+ } ,
79
116
'transactionId' : 'bid_id_1_transaction_id'
80
117
} ,
81
118
{
@@ -97,6 +134,33 @@ describe('Adyoulike Adapter', function () {
97
134
}
98
135
] ;
99
136
137
+ const requestDataOnePlacement = {
138
+ 'bid_id_0' :
139
+ { 'PlacementID' : 'e622af275681965d3095808561a1e510' ,
140
+ 'TransactionID' : '1bca18cc-c0fe-439b-88c2-8247d3448f22' ,
141
+ 'Width' : 300 ,
142
+ 'Height' : 600 ,
143
+ 'AvailableSizes' : '300x600'
144
+ }
145
+ }
146
+
147
+ const requestDataMultiPlacement = {
148
+ 'bid_id_0' :
149
+ { 'PlacementID' : 'e622af275681965d3095808561a1e510' ,
150
+ 'TransactionID' : '1bca18cc-c0fe-439b-88c2-8247d3448f22' ,
151
+ 'Width' : 300 ,
152
+ 'Height' : 600 ,
153
+ 'AvailableSizes' : '300x600'
154
+ } ,
155
+ 'bid_id_1' :
156
+ { 'PlacementID' : 'e622af275681965d3095808561a1e510' ,
157
+ 'TransactionID' : 'e63b2d86-ca60-4167-9cf1-497607079634' ,
158
+ 'Width' : 400 ,
159
+ 'Height' : 250 ,
160
+ 'AvailableSizes' : '300x250'
161
+ }
162
+ }
163
+
100
164
const responseWithEmptyPlacement = [
101
165
{
102
166
'Placement' : 'placement_0'
@@ -108,8 +172,7 @@ describe('Adyoulike Adapter', function () {
108
172
'Placement' : 'placement_0' ,
109
173
'Ad' : 'placement_0' ,
110
174
'Price' : 0.5 ,
111
- 'Height' : 300 ,
112
- 'Width' : 300 ,
175
+ 'Height' : 600 ,
113
176
}
114
177
] ;
115
178
const responseWithMultiplePlacements = [
@@ -118,16 +181,16 @@ describe('Adyoulike Adapter', function () {
118
181
'Placement' : 'placement_0' ,
119
182
'Ad' : 'placement_0' ,
120
183
'Price' : 0.5 ,
121
- 'Height' : 300 ,
122
- 'Width' : 300 ,
184
+ 'Height' : 0 , // test with wrong value
185
+ 'Width' : 300
123
186
} ,
124
187
{
125
188
'BidID' : 'bid_id_1' ,
126
189
'Placement' : 'placement_1' ,
127
190
'Ad' : 'placement_1' ,
128
191
'Price' : 0.6 ,
129
- 'Height' : 300 ,
130
- 'Width' : 300 ,
192
+ 'Height' : 250
193
+ // 'Width' test with missing value
131
194
}
132
195
] ;
133
196
const adapter = newBidder ( spec ) ;
@@ -189,16 +252,6 @@ describe('Adyoulike Adapter', function () {
189
252
} ) ;
190
253
191
254
it ( 'should add gdpr consent information to the request' , function ( ) {
192
- let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' ;
193
- let bidderRequest = {
194
- 'auctionId' : '1d1a030790a475' ,
195
- 'bidderRequestId' : '22edbae2733bf6' ,
196
- 'timeout' : 3000 ,
197
- 'gdprConsent' : {
198
- consentString : consentString ,
199
- gdprApplies : true
200
- }
201
- } ;
202
255
bidderRequest . bids = bidRequestWithSinglePlacement ;
203
256
204
257
const request = spec . buildRequests ( bidRequestWithSinglePlacement , bidderRequest ) ;
@@ -210,12 +263,13 @@ describe('Adyoulike Adapter', function () {
210
263
} ) ;
211
264
212
265
it ( 'sends bid request to endpoint with single placement' , function ( ) {
213
- const request = spec . buildRequests ( bidRequestWithSinglePlacement ) ;
266
+ const request = spec . buildRequests ( bidRequestWithSinglePlacement , bidderRequest ) ;
214
267
const payload = JSON . parse ( request . data ) ;
215
268
216
269
expect ( request . url ) . to . contain ( getEndpoint ( ) ) ;
217
270
expect ( request . method ) . to . equal ( 'POST' ) ;
218
271
expect ( request . url ) . to . contains ( 'CanonicalUrl=' + encodeURIComponent ( canonicalUrl ) ) ;
272
+ expect ( request . url ) . to . contains ( 'RefererUrl=' + encodeURIComponent ( referrerUrl ) ) ;
219
273
220
274
expect ( payload . Version ) . to . equal ( '1.0' ) ;
221
275
expect ( payload . Bids [ 'bid_id_0' ] . PlacementID ) . to . be . equal ( 'placement_0' ) ;
@@ -225,7 +279,7 @@ describe('Adyoulike Adapter', function () {
225
279
226
280
it ( 'sends bid request to endpoint with single placement without canonical' , function ( ) {
227
281
canonicalQuery . restore ( ) ;
228
- const request = spec . buildRequests ( bidRequestWithSinglePlacement ) ;
282
+ const request = spec . buildRequests ( bidRequestWithSinglePlacement , bidderRequest ) ;
229
283
const payload = JSON . parse ( request . data ) ;
230
284
231
285
expect ( request . url ) . to . contain ( getEndpoint ( ) ) ;
@@ -239,12 +293,13 @@ describe('Adyoulike Adapter', function () {
239
293
} ) ;
240
294
241
295
it ( 'sends bid request to endpoint with multiple placements' , function ( ) {
242
- const request = spec . buildRequests ( bidRequestMultiPlacements ) ;
296
+ const request = spec . buildRequests ( bidRequestMultiPlacements , bidderRequest ) ;
243
297
const payload = JSON . parse ( request . data ) ;
244
298
expect ( request . url ) . to . contain ( getEndpoint ( ) ) ;
245
299
expect ( request . method ) . to . equal ( 'POST' ) ;
246
300
247
301
expect ( request . url ) . to . contains ( 'CanonicalUrl=' + encodeURIComponent ( canonicalUrl ) ) ;
302
+ expect ( request . url ) . to . contains ( 'RefererUrl=' + encodeURIComponent ( referrerUrl ) ) ;
248
303
249
304
expect ( payload . Version ) . to . equal ( '1.0' ) ;
250
305
@@ -259,7 +314,7 @@ describe('Adyoulike Adapter', function () {
259
314
} ) ;
260
315
261
316
it ( 'sends bid request to endpoint setted by parameters' , function ( ) {
262
- const request = spec . buildRequests ( bidRequestWithDCPlacement ) ;
317
+ const request = spec . buildRequests ( bidRequestWithDCPlacement , bidderRequest ) ;
263
318
const payload = JSON . parse ( request . data ) ;
264
319
265
320
expect ( request . url ) . to . contain ( getEndpoint ( `${ defaultDC } -fra01` ) ) ;
@@ -288,30 +343,30 @@ describe('Adyoulike Adapter', function () {
288
343
289
344
it ( 'receive reponse with single placement' , function ( ) {
290
345
serverResponse . body = responseWithSinglePlacement ;
291
- let result = spec . interpretResponse ( serverResponse , bidRequestWithSinglePlacement ) ;
346
+ let result = spec . interpretResponse ( serverResponse , { data : '{"Bids":' + JSON . stringify ( requestDataOnePlacement ) + '}' } ) ;
292
347
293
348
expect ( result . length ) . to . equal ( 1 ) ;
294
349
expect ( result [ 0 ] . cpm ) . to . equal ( 0.5 ) ;
295
350
expect ( result [ 0 ] . ad ) . to . equal ( 'placement_0' ) ;
296
351
expect ( result [ 0 ] . width ) . to . equal ( 300 ) ;
297
- expect ( result [ 0 ] . height ) . to . equal ( 300 ) ;
352
+ expect ( result [ 0 ] . height ) . to . equal ( 600 ) ;
298
353
} ) ;
299
354
300
355
it ( 'receive reponse with multiple placement' , function ( ) {
301
356
serverResponse . body = responseWithMultiplePlacements ;
302
- let result = spec . interpretResponse ( serverResponse , bidRequestMultiPlacements ) ;
357
+ let result = spec . interpretResponse ( serverResponse , { data : '{"Bids":' + JSON . stringify ( requestDataMultiPlacement ) + '}' } ) ;
303
358
304
359
expect ( result . length ) . to . equal ( 2 ) ;
305
360
306
361
expect ( result [ 0 ] . cpm ) . to . equal ( 0.5 ) ;
307
362
expect ( result [ 0 ] . ad ) . to . equal ( 'placement_0' ) ;
308
363
expect ( result [ 0 ] . width ) . to . equal ( 300 ) ;
309
- expect ( result [ 0 ] . height ) . to . equal ( 300 ) ;
364
+ expect ( result [ 0 ] . height ) . to . equal ( 600 ) ;
310
365
311
366
expect ( result [ 1 ] . cpm ) . to . equal ( 0.6 ) ;
312
367
expect ( result [ 1 ] . ad ) . to . equal ( 'placement_1' ) ;
313
- expect ( result [ 1 ] . width ) . to . equal ( 300 ) ;
314
- expect ( result [ 1 ] . height ) . to . equal ( 300 ) ;
368
+ expect ( result [ 1 ] . width ) . to . equal ( 400 ) ;
369
+ expect ( result [ 1 ] . height ) . to . equal ( 250 ) ;
315
370
} ) ;
316
371
} ) ;
317
372
} ) ;
0 commit comments