1
1
import { expect } from 'chai' ;
2
2
import { spec } from 'modules/adfusionBidAdapter' ;
3
3
import 'modules/priceFloors.js' ;
4
+ import 'modules/currency.js' ;
4
5
import { newBidder } from 'src/adapters/bidderFactory' ;
5
6
6
7
describe ( 'adfusionBidAdapter' , function ( ) {
@@ -24,7 +25,7 @@ describe('adfusionBidAdapter', function () {
24
25
transactionId : 'test-transactionId-1' ,
25
26
} ;
26
27
27
- it ( 'should return true when required params found' , function ( ) {
28
+ it ( 'should return true when required params are found' , function ( ) {
28
29
expect ( spec . isBidRequestValid ( bid ) ) . to . equal ( true ) ;
29
30
} ) ;
30
31
@@ -36,7 +37,7 @@ describe('adfusionBidAdapter', function () {
36
37
} ) ;
37
38
38
39
describe ( 'buildRequests' , function ( ) {
39
- let bidRequests , bidderRequest ;
40
+ let bidRequests , bannerBidRequest , bidderRequest ;
40
41
beforeEach ( function ( ) {
41
42
bidRequests = [
42
43
{
@@ -75,6 +76,25 @@ describe('adfusionBidAdapter', function () {
75
76
transactionId : 'test-transactionId-2' ,
76
77
} ,
77
78
] ;
79
+ bannerBidRequest = {
80
+ bidder : 'adfusion' ,
81
+ params : {
82
+ accountId : 1234 ,
83
+ } ,
84
+ mediaTypes : {
85
+ banner : {
86
+ sizes : [
87
+ [ 300 , 250 ] ,
88
+ [ 300 , 600 ] ,
89
+ ] ,
90
+ } ,
91
+ } ,
92
+ adUnitCode : '/adunit-code/test-path' ,
93
+ bidId : 'test-bid-id-1' ,
94
+ bidderRequestId : 'test-bid-request-1' ,
95
+ auctionId : 'test-auction-1' ,
96
+ transactionId : 'test-transactionId-1' ,
97
+ } ;
78
98
bidderRequest = { refererInfo : { } } ;
79
99
} ) ;
80
100
@@ -89,9 +109,22 @@ describe('adfusionBidAdapter', function () {
89
109
expect ( request ) . to . be . an ( 'array' ) ;
90
110
expect ( request [ 0 ] . data ) . to . be . an ( 'object' ) ;
91
111
expect ( request [ 0 ] . method ) . to . equal ( 'POST' ) ;
112
+ expect ( request [ 0 ] . currency ) . to . not . equal ( 'USD' ) ;
92
113
expect ( request [ 0 ] . url ) . to . not . equal ( '' ) ;
93
114
expect ( request [ 0 ] . url ) . to . not . equal ( undefined ) ;
94
115
expect ( request [ 0 ] . url ) . to . not . equal ( null ) ;
95
116
} ) ;
117
+
118
+ it ( 'should add bid floor' , function ( ) {
119
+ let bidRequest = Object . assign ( { } , bannerBidRequest ) ;
120
+ let payload = spec . buildRequests ( [ bidRequest ] , bidderRequest ) [ 0 ] . data ;
121
+ expect ( payload . imp [ 0 ] . bidfloorcur ) . to . not . exist ;
122
+
123
+ let getFloorResponse = { currency : 'USD' , floor : 3 } ;
124
+ bidRequest . getFloor = ( ) => getFloorResponse ;
125
+ payload = spec . buildRequests ( [ bidRequest ] , bidderRequest ) [ 0 ] . data ;
126
+ expect ( payload . imp [ 0 ] . bidfloor ) . to . equal ( 3 ) ;
127
+ expect ( payload . imp [ 0 ] . bidfloorcur ) . to . equal ( 'USD' ) ;
128
+ } ) ;
96
129
} ) ;
97
130
} ) ;
0 commit comments