@@ -7,6 +7,28 @@ import { hasTypeNative } from '../../../modules/onetagBidAdapter';
7
7
8
8
const NATIVE_SUFFIX = 'Ad' ;
9
9
10
+ const getFloor = function ( params ) {
11
+ let floorPrice = 0.0001 ;
12
+ switch ( params . mediaType ) {
13
+ case BANNER :
14
+ floorPrice = 1.0 ;
15
+ break ;
16
+ case VIDEO :
17
+ floorPrice = 2.0 ;
18
+ break ;
19
+ case INSTREAM :
20
+ floorPrice = 3.0 ;
21
+ break ;
22
+ case OUTSTREAM :
23
+ floorPrice = 4.0 ;
24
+ break ;
25
+ case NATIVE :
26
+ floorPrice = 5.0 ;
27
+ break ;
28
+ }
29
+ return { currency : params . currency , floor : floorPrice } ;
30
+ } ;
31
+
10
32
describe ( 'onetag' , function ( ) {
11
33
function createBid ( ) {
12
34
return {
@@ -84,6 +106,17 @@ describe('onetag', function () {
84
106
bid . mediaTypes . native = { } ;
85
107
bid . mediaTypes . native . adTemplate = bid . nativeParams . adTemplate ;
86
108
bid . mediaTypes . native . ortb = ortbConversion ;
109
+ bid . floors = {
110
+ currency : 'EUR' ,
111
+ schema : {
112
+ delimiter : '|' ,
113
+ fields : [ 'mediaType' , 'size' ]
114
+ } ,
115
+ values : {
116
+ 'native|*' : 1.10
117
+ }
118
+ }
119
+ bid . getFloor = getFloor ;
87
120
return bid ;
88
121
}
89
122
@@ -106,7 +139,7 @@ describe('onetag', function () {
106
139
assets : [ {
107
140
id : 1 ,
108
141
required : 1 ,
109
- title : {
142
+ title : {
110
143
len : 140
111
144
}
112
145
} ,
@@ -142,6 +175,19 @@ describe('onetag', function () {
142
175
} ]
143
176
}
144
177
} ;
178
+
179
+ bid . floors = {
180
+ currency : 'EUR' ,
181
+ schema : {
182
+ delimiter : '|' ,
183
+ fields : [ 'mediaType' , 'size' ]
184
+ } ,
185
+ values : {
186
+ 'native|*' : 1.10
187
+ }
188
+ }
189
+ bid . getFloor = getFloor ;
190
+
145
191
return bid ;
146
192
}
147
193
@@ -151,6 +197,18 @@ describe('onetag', function () {
151
197
bid . mediaTypes . banner = {
152
198
sizes : [ [ 300 , 250 ] ]
153
199
} ;
200
+ bid . floors = {
201
+ currency : 'EUR' ,
202
+ schema : {
203
+ delimiter : '|' ,
204
+ fields : [ 'mediaType' , 'size' ]
205
+ } ,
206
+ values : {
207
+ 'banner|300x250' : 0.10
208
+ }
209
+ }
210
+ bid . getFloor = getFloor ;
211
+
154
212
return bid ;
155
213
}
156
214
@@ -162,6 +220,17 @@ describe('onetag', function () {
162
220
mimes : [ 'video/mp4' , 'video/webm' , 'application/javascript' , 'video/ogg' ] ,
163
221
playerSize : [ 640 , 480 ]
164
222
} ;
223
+ bid . floors = {
224
+ currency : 'EUR' ,
225
+ schema : {
226
+ delimiter : '|' ,
227
+ fields : [ 'mediaType' , 'size' ]
228
+ } ,
229
+ values : {
230
+ 'video|640x480' : 0.10
231
+ }
232
+ }
233
+ bid . getFloor = getFloor ;
165
234
return bid ;
166
235
}
167
236
@@ -173,6 +242,17 @@ describe('onetag', function () {
173
242
mimes : [ 'video/mp4' , 'video/webm' , 'application/javascript' , 'video/ogg' ] ,
174
243
playerSize : [ 640 , 480 ]
175
244
} ;
245
+ bid . floors = {
246
+ currency : 'EUR' ,
247
+ schema : {
248
+ delimiter : '|' ,
249
+ fields : [ 'mediaType' , 'size' ]
250
+ } ,
251
+ values : {
252
+ 'video|640x480' : 0.10
253
+ }
254
+ }
255
+ bid . getFloor = getFloor ;
176
256
return bid ;
177
257
}
178
258
@@ -483,6 +563,33 @@ describe('onetag', function () {
483
563
}
484
564
expect ( bid . bidId ) . to . be . a ( 'string' ) ;
485
565
expect ( bid . pubId ) . to . be . a ( 'string' ) ;
566
+ expect ( bid . priceFloors ) . to . be . an ( 'array' ) ;
567
+ expect ( bid . priceFloors ) . to . satisfy ( function ( priceFloors ) {
568
+ if ( priceFloors . length === 0 ) {
569
+ return true ;
570
+ }
571
+ return priceFloors . every ( function ( priceFloor ) {
572
+ expect ( priceFloor ) . to . have . all . keys ( 'currency' , 'floor' , 'size' ) ;
573
+ expect ( priceFloor . currency ) . to . be . a ( 'string' ) ;
574
+ expect ( priceFloor . floor ) . to . be . a ( 'number' ) ;
575
+ expect ( priceFloor . size ) . to . satisfy ( function ( size ) {
576
+ if ( typeof size !== 'object' && size !== null && typeof size !== 'undefined' ) {
577
+ return false ;
578
+ }
579
+ if ( size !== null ) {
580
+ const keys = Object . keys ( size ) ;
581
+ if ( keys . length == 0 ) {
582
+ return true ;
583
+ }
584
+ expect ( size ) . to . have . keys ( 'width' , 'height' ) ;
585
+ expect ( size . width ) . to . be . a ( 'number' ) ;
586
+ expect ( size . height ) . to . be . a ( 'number' ) ;
587
+ }
588
+ return true ;
589
+ } ) ;
590
+ return true ;
591
+ } ) ;
592
+ } ) ;
486
593
}
487
594
} ) ;
488
595
it ( 'Returns empty data if no valid requests are passed' , function ( ) {
0 commit comments