|
1 | 1 | import { expect } from 'chai'
|
2 | 2 | import { spec } from 'modules/voxBidAdapter.js'
|
| 3 | +import {config} from 'src/config.js' |
3 | 4 |
|
4 | 5 | function getSlotConfigs(mediaTypes, params) {
|
5 | 6 | return {
|
@@ -175,6 +176,98 @@ describe('VOX Adapter', function() {
|
175 | 176 | expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459')
|
176 | 177 | })
|
177 | 178 | })
|
| 179 | + it('should not set userid if not specified', function () { |
| 180 | + const request = spec.buildRequests(validBidRequests, bidderRequest) |
| 181 | + const data = JSON.parse(request.data) |
| 182 | + data.bidRequests.forEach(bid => { |
| 183 | + expect(bid.userId).to.be.undefined |
| 184 | + }) |
| 185 | + }) |
| 186 | + |
| 187 | + it('should set userid if specified', function () { |
| 188 | + const requests = validBidRequests.map(bid => ({ |
| 189 | + ...bid, |
| 190 | + userId: { |
| 191 | + tdid: 'TDID_USER_ID', |
| 192 | + pubcid: 'PUBID_USER_ID' |
| 193 | + } |
| 194 | + })) |
| 195 | + const request = spec.buildRequests(requests, bidderRequest) |
| 196 | + const data = JSON.parse(request.data) |
| 197 | + data.bidRequests.forEach(bid => { |
| 198 | + expect(bid.userId.tdid).to.equal('TDID_USER_ID') |
| 199 | + expect(bid.userId.pubcid).to.equal('PUBID_USER_ID') |
| 200 | + }) |
| 201 | + }) |
| 202 | + |
| 203 | + it('should not set schain if not specified', function () { |
| 204 | + const request = spec.buildRequests(validBidRequests, bidderRequest) |
| 205 | + const data = JSON.parse(request.data) |
| 206 | + data.bidRequests.forEach(bid => { |
| 207 | + expect(bid.schain).to.be.undefined |
| 208 | + }) |
| 209 | + }) |
| 210 | + |
| 211 | + it('should set schain if not specified', function () { |
| 212 | + const requests = validBidRequests.map(bid => ({ |
| 213 | + ...bid, |
| 214 | + schain: { |
| 215 | + validation: 'strict', |
| 216 | + config: { |
| 217 | + ver: '1.0' |
| 218 | + } |
| 219 | + } |
| 220 | + })) |
| 221 | + const request = spec.buildRequests(requests, bidderRequest) |
| 222 | + const data = JSON.parse(request.data) |
| 223 | + data.bidRequests.forEach(bid => { |
| 224 | + expect(bid.schain.validation).to.equal('strict') |
| 225 | + expect(bid.schain.config.ver).to.equal('1.0') |
| 226 | + }) |
| 227 | + }) |
| 228 | + |
| 229 | + describe('price floors', function () { |
| 230 | + it('should be empty if floors module not configured', function () { |
| 231 | + const request = spec.buildRequests(validBidRequests, bidderRequest) |
| 232 | + const data = JSON.parse(request.data) |
| 233 | + data.bidRequests.forEach(bid => { |
| 234 | + expect(bid.floorInfo).to.be.empty |
| 235 | + }) |
| 236 | + }) |
| 237 | + |
| 238 | + it('should add correct floor values', function () { |
| 239 | + const expectedFloors = [ 2, 2.7, 1.4 ] |
| 240 | + const validBidRequests = expectedFloors.map(getBidWithFloor) |
| 241 | + const request = spec.buildRequests(validBidRequests, bidderRequest) |
| 242 | + const data = JSON.parse(request.data) |
| 243 | + expectedFloors.forEach((floor, index) => { |
| 244 | + expect(data.bidRequests[index].floorInfo.floor).to.equal(floor) |
| 245 | + expect(data.bidRequests[index].floorInfo.currency).to.equal('USD') |
| 246 | + }) |
| 247 | + }) |
| 248 | + |
| 249 | + it('should request floor price in adserver currency', function () { |
| 250 | + const configCurrency = 'DKK' |
| 251 | + config.setConfig({ currency: { adServerCurrency: configCurrency } }) |
| 252 | + const request = spec.buildRequests([ getBidWithFloor() ], bidderRequest) |
| 253 | + const data = JSON.parse(request.data) |
| 254 | + data.bidRequests.forEach(bid => { |
| 255 | + expect(bid.floorInfo.currency).to.equal(configCurrency) |
| 256 | + }) |
| 257 | + }) |
| 258 | + |
| 259 | + function getBidWithFloor(floor) { |
| 260 | + return { |
| 261 | + ...validBidRequests[0], |
| 262 | + getFloor: ({ currency }) => { |
| 263 | + return { |
| 264 | + currency: currency, |
| 265 | + floor |
| 266 | + } |
| 267 | + } |
| 268 | + } |
| 269 | + } |
| 270 | + }) |
178 | 271 |
|
179 | 272 | describe('GDPR params', function() {
|
180 | 273 | describe('when there are not consent management platform', function() {
|
|
0 commit comments