@@ -8,7 +8,12 @@ const SUPPLY_CODE = 'ssp-demo-rm6rh';
8
8
const SIZES = [ 640 , 480 ] ;
9
9
const REQUEST = {
10
10
'code' : 'video1' ,
11
- 'sizes' : [ 640 , 480 ] ,
11
+ 'mediaTypes' : {
12
+ 'video' : {
13
+ 'playerSize' : [ [ 640 , 480 ] ] ,
14
+ 'context' : 'instream'
15
+ }
16
+ } ,
12
17
'mediaType' : 'video' ,
13
18
'bids' : [ {
14
19
'bidder' : 'tremor' ,
@@ -19,6 +24,12 @@ const REQUEST = {
19
24
} ]
20
25
} ;
21
26
27
+ const BIDDER_REQUEST = {
28
+ 'refererInfo' : {
29
+ 'referer' : 'www.test.com'
30
+ }
31
+ } ;
32
+
22
33
const RESPONSE = {
23
34
'cur' : 'USD' ,
24
35
'id' : '3dba13e35f3d42f998bc7e65fd871889' ,
@@ -34,26 +45,26 @@ const RESPONSE = {
34
45
} ]
35
46
} ;
36
47
37
- describe ( 'TelariaAdapter' , function ( ) {
48
+ describe ( 'TelariaAdapter' , ( ) => {
38
49
const adapter = newBidder ( spec ) ;
39
50
40
- describe ( 'inherited functions' , function ( ) {
41
- it ( 'exists and is a function' , function ( ) {
51
+ describe ( 'inherited functions' , ( ) => {
52
+ it ( 'exists and is a function' , ( ) => {
42
53
expect ( adapter . callBids ) . to . exist . and . to . be . a ( 'function' ) ;
43
54
} ) ;
44
55
} ) ;
45
56
46
- describe ( 'isBidRequestValid' , function ( ) {
57
+ describe ( 'isBidRequestValid' , ( ) => {
47
58
let bid = REQUEST . bids [ 0 ] ;
48
59
49
- it ( 'should return true when required params found' , function ( ) {
60
+ it ( 'should return true when required params found' , ( ) => {
50
61
let tempBid = bid ;
51
62
tempBid . params . adCode = 'ssp-!demo!-lufip' ;
52
63
tempBid . params . supplyCode = 'ssp-demo-rm6rh' ;
53
64
expect ( spec . isBidRequestValid ( bid ) ) . to . equal ( true ) ;
54
65
} ) ;
55
66
56
- it ( 'should return true when required params found' , function ( ) {
67
+ it ( 'should return true when required params found' , ( ) => {
57
68
let tempBid = bid ;
58
69
delete tempBid . params ;
59
70
tempBid . params = {
@@ -64,35 +75,40 @@ describe('TelariaAdapter', function () {
64
75
expect ( spec . isBidRequestValid ( tempBid ) ) . to . equal ( true ) ;
65
76
} ) ;
66
77
67
- it ( 'should return false when required params are not passed' , function ( ) {
78
+ it ( 'should return false when required params are not passed' , ( ) => {
68
79
let tempBid = bid ;
69
80
tempBid . params = { } ;
70
81
expect ( spec . isBidRequestValid ( tempBid ) ) . to . equal ( false ) ;
71
82
} ) ;
72
83
} ) ;
73
84
74
- describe ( 'buildRequests' , function ( ) {
85
+ describe ( 'buildRequests' , ( ) => {
75
86
const stub = [ {
87
+ mediaTypes : {
88
+ video : {
89
+ playerSize : [ [ 640 , 480 ] ] ,
90
+ context : 'instream'
91
+ }
92
+ } ,
76
93
bidder : 'tremor' ,
77
- sizes : [ [ 300 , 250 ] , [ 300 , 600 ] ] ,
78
94
params : {
79
95
supplyCode : 'ssp-demo-rm6rh' ,
80
96
adCode : 'ssp-!demo!-lufip' ,
81
97
videoId : 'MyCoolVideo'
82
98
}
83
99
} ] ;
84
100
85
- it ( 'exists and is a function' , function ( ) {
101
+ it ( 'exists and is a function' , ( ) => {
86
102
expect ( spec . buildRequests ) . to . exist . and . to . be . a ( 'function' ) ;
87
103
} ) ;
88
104
89
- it ( 'requires supply code, ad code and sizes to make a request' , function ( ) {
90
- const tempRequest = spec . buildRequests ( stub ) ;
105
+ it ( 'requires supply code & ad code to make a request' , ( ) => {
106
+ const tempRequest = spec . buildRequests ( stub , BIDDER_REQUEST ) ;
91
107
expect ( tempRequest . length ) . to . equal ( 1 ) ;
92
108
} ) ;
93
109
94
- it ( 'generates an array of requests with 4 params, method, url, bidId and vastUrl' , function ( ) {
95
- const tempRequest = spec . buildRequests ( stub ) ;
110
+ it ( 'generates an array of requests with 4 params, method, url, bidId and vastUrl' , ( ) => {
111
+ const tempRequest = spec . buildRequests ( stub , BIDDER_REQUEST ) ;
96
112
97
113
expect ( tempRequest . length ) . to . equal ( 1 ) ;
98
114
expect ( tempRequest [ 0 ] . method ) . to . equal ( 'GET' ) ;
@@ -101,77 +117,85 @@ describe('TelariaAdapter', function () {
101
117
expect ( tempRequest [ 0 ] . vastUrl ) . to . exist ;
102
118
} ) ;
103
119
104
- it ( 'requires sizes to make a request ' , function ( ) {
120
+ it ( 'doesn\'t require player size but is highly recommended ' , ( ) => {
105
121
let tempBid = stub ;
106
- tempBid [ 0 ] . sizes = null ;
107
- const tempRequest = spec . buildRequests ( tempBid ) ;
122
+ tempBid [ 0 ] . mediaTypes . video . playerSize = null ;
123
+ const tempRequest = spec . buildRequests ( tempBid , BIDDER_REQUEST ) ;
108
124
109
- expect ( tempRequest . length ) . to . equal ( 0 ) ;
125
+ expect ( tempRequest . length ) . to . equal ( 1 ) ;
110
126
} ) ;
111
127
112
- it ( 'generates a valid request with sizes as an array of two elements' , function ( ) {
128
+ it ( 'generates a valid request with sizes as an array of two elements' , ( ) => {
113
129
let tempBid = stub ;
114
- tempBid [ 0 ] . sizes = [ 640 , 480 ] ;
115
- expect ( spec . buildRequests ( tempBid ) . length ) . to . equal ( 1 ) ;
130
+ tempBid [ 0 ] . mediaTypes . video . playerSize = [ 640 , 480 ] ;
131
+ tempBid [ 0 ] . params . adCode = 'ssp-!demo!-lufip' ;
132
+ tempBid [ 0 ] . params . supplyCode = 'ssp-demo-rm6rh' ;
133
+ let builtRequests = spec . buildRequests ( tempBid , BIDDER_REQUEST ) ;
134
+ expect ( builtRequests . length ) . to . equal ( 1 ) ;
116
135
} ) ;
117
136
118
- it ( 'requires ad code and supply code to make a request' , function ( ) {
137
+ it ( 'requires ad code and supply code to make a request' , ( ) => {
119
138
let tempBid = stub ;
120
139
tempBid [ 0 ] . params . adCode = null ;
121
140
tempBid [ 0 ] . params . supplyCode = null ;
122
141
123
- const tempRequest = spec . buildRequests ( tempBid ) ;
142
+ const tempRequest = spec . buildRequests ( tempBid , BIDDER_REQUEST ) ;
124
143
125
144
expect ( tempRequest . length ) . to . equal ( 0 ) ;
126
145
} ) ;
127
146
} ) ;
128
147
129
- describe ( 'interpretResponse' , function ( ) {
148
+ describe ( 'interpretResponse' , ( ) => {
130
149
const responseStub = RESPONSE ;
131
150
const stub = [ {
151
+ mediaTypes : {
152
+ video : {
153
+ playerSize : [ [ 640 , 480 ] ] ,
154
+ context : 'instream'
155
+ }
156
+ } ,
132
157
bidder : 'tremor' ,
133
- sizes : [ [ 300 , 250 ] , [ 300 , 600 ] ] ,
134
158
params : {
135
159
supplyCode : 'ssp-demo-rm6rh' ,
136
160
adCode : 'ssp-!demo!-lufip' ,
137
161
videoId : 'MyCoolVideo'
138
162
}
139
163
} ] ;
140
164
141
- it ( 'should get correct bid response' , function ( ) {
165
+ it ( 'should get correct bid response' , ( ) => {
142
166
let expectedResponseKeys = [ 'bidderCode' , 'width' , 'height' , 'statusMessage' , 'adId' , 'mediaType' , 'source' ,
143
167
'getStatusCode' , 'getSize' , 'requestId' , 'cpm' , 'creativeId' , 'vastXml' ,
144
168
'vastUrl' , 'currency' , 'netRevenue' , 'ttl' , 'ad' ] ;
145
169
146
- let bidRequest = spec . buildRequests ( stub ) [ 0 ] ;
170
+ let bidRequest = spec . buildRequests ( stub , BIDDER_REQUEST ) [ 0 ] ;
147
171
bidRequest . bidId = '1234' ;
148
172
let result = spec . interpretResponse ( { body : responseStub } , bidRequest ) ;
149
173
expect ( Object . keys ( result [ 0 ] ) ) . to . have . members ( expectedResponseKeys ) ;
150
174
} ) ;
151
175
152
- it ( 'handles nobid responses' , function ( ) {
176
+ it ( 'handles nobid responses' , ( ) => {
153
177
let tempResponse = responseStub ;
154
178
tempResponse . seatbid = [ ] ;
155
179
156
- let bidRequest = spec . buildRequests ( stub ) [ 0 ] ;
180
+ let bidRequest = spec . buildRequests ( stub , BIDDER_REQUEST ) [ 0 ] ;
157
181
bidRequest . bidId = '1234' ;
158
182
159
183
let result = spec . interpretResponse ( { body : tempResponse } , bidRequest ) ;
160
184
expect ( result . length ) . to . equal ( 0 ) ;
161
185
} ) ;
162
186
163
- it ( 'handles invalid responses' , function ( ) {
187
+ it ( 'handles invalid responses' , ( ) => {
164
188
let result = spec . interpretResponse ( null , { bbidderCode : 'telaria' } ) ;
165
189
expect ( result . length ) . to . equal ( 0 ) ;
166
190
} ) ;
167
191
168
- it ( 'handles error responses' , function ( ) {
192
+ it ( 'handles error responses' , ( ) => {
169
193
let result = spec . interpretResponse ( { body : { error : 'Invalid request' } } , { bbidderCode : 'telaria' } ) ;
170
194
expect ( result . length ) . to . equal ( 0 ) ;
171
195
} ) ;
172
196
} ) ;
173
197
174
- describe ( 'getUserSyncs' , function ( ) {
198
+ describe ( 'getUserSyncs' , ( ) => {
175
199
const responses = [ { body : RESPONSE } ] ;
176
200
responses [ 0 ] . body . ext = {
177
201
telaria : {
@@ -182,7 +206,7 @@ describe('TelariaAdapter', function () {
182
206
}
183
207
} ;
184
208
185
- it ( 'should get the correct number of sync urls' , function ( ) {
209
+ it ( 'should get the correct number of sync urls' , ( ) => {
186
210
let urls = spec . getUserSyncs ( { pixelEnabled : true } , responses ) ;
187
211
expect ( urls . length ) . to . equal ( 2 ) ;
188
212
} ) ;
0 commit comments