-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathadfusionBidAdapter_spec.js
More file actions
130 lines (121 loc) · 3.99 KB
/
adfusionBidAdapter_spec.js
File metadata and controls
130 lines (121 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { expect } from 'chai';
import { spec } from 'modules/adfusionBidAdapter';
import 'modules/priceFloors.js';
import 'modules/currency.js';
import { newBidder } from 'src/adapters/bidderFactory';
describe('adfusionBidAdapter', function () {
const adapter = newBidder(spec);
describe('inherited functions', function () {
it('exists and is a function', function () {
expect(adapter.callBids).to.exist.and.to.be.a('function');
});
});
describe('isBidRequestValid', function () {
const bid = {
bidder: 'adfusion',
params: {
accountId: 1234,
},
adUnitCode: '/adunit-code/test-path',
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1',
transactionId: 'test-transactionId-1',
};
it('should return true when required params are found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
it('should return false when params.accountID is missing', function () {
const localbid = Object.assign({}, bid);
delete localbid.params.accountId;
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
});
describe('buildRequests', function () {
let bidRequests, bannerBidRequest, bidderRequest;
beforeEach(function () {
bidRequests = [
{
bidder: 'adfusion',
params: {
accountId: 1234,
},
mediaTypes: {
banner: {
sizes: [
[300, 250],
[300, 600],
],
},
},
adUnitCode: '/adunit-code/test-path',
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1',
transactionId: 'test-transactionId-1',
},
{
bidder: 'adfusion',
params: {
accountId: 1234,
},
adUnitCode: 'adunit-code',
mediaTypes: {
video: {
playerSize: [640, 480],
},
},
bidId: 'test-bid-id-2',
bidderRequestId: 'test-bid-request-2',
auctionId: 'test-auction-2',
transactionId: 'test-transactionId-2',
},
];
bannerBidRequest = {
bidder: 'adfusion',
params: {
accountId: 1234,
},
mediaTypes: {
banner: {
sizes: [
[300, 250],
[300, 600],
],
},
},
adUnitCode: '/adunit-code/test-path',
bidId: 'test-bid-id-1',
bidderRequestId: 'test-bid-request-1',
auctionId: 'test-auction-1',
transactionId: 'test-transactionId-1',
};
bidderRequest = { refererInfo: {} };
});
it('should return an empty array when no bid requests', function () {
const bidRequest = spec.buildRequests([], bidderRequest);
expect(bidRequest).to.be.an('array');
expect(bidRequest.length).to.equal(0);
});
it('should return a valid bid request object', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request).to.be.an('array');
expect(request[0].data).to.be.an('object');
expect(request[0].method).to.equal('POST');
expect(request[0].currency).to.not.equal('USD');
expect(request[0].url).to.not.equal('');
expect(request[0].url).to.not.equal(undefined);
expect(request[0].url).to.not.equal(null);
});
it('should add bid floor', function () {
const bidRequest = Object.assign({}, bannerBidRequest);
let payload = spec.buildRequests([bidRequest], bidderRequest)[0].data;
expect(payload.imp[0].bidfloorcur).to.not.exist;
const getFloorResponse = { currency: 'USD', floor: 3 };
bidRequest.getFloor = () => getFloorResponse;
payload = spec.buildRequests([bidRequest], bidderRequest)[0].data;
expect(payload.imp[0].bidfloor).to.equal(3);
expect(payload.imp[0].bidfloorcur).to.equal('USD');
});
});
});