Repository navigation
Expand file tree
/
Copy pathablidaBidAdapter_spec.js
More file actions
152 lines (140 loc) · 4.11 KB
/
Copy pathablidaBidAdapter_spec.js
File metadata and controls
152 lines (140 loc) · 4.11 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import { expect } from 'chai';
import { spec } from 'modules/ablidaBidAdapter.js';
import * as utils from 'src/utils.js';
const ENDPOINT_URL = 'https://bidder.ablida.net/prebid';
describe('ablidaBidAdapter', function () {
describe('isBidRequestValid', function () {
const bid = {
adUnitCode: 'adunit-code',
auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0',
bidRequestsCount: 1,
bidder: 'ablida',
bidderRequestId: '14d2939272a26a',
bidderRequestsCount: 1,
bidderWinsCount: 0,
bidId: '1234asdf1234',
mediaTypes: { banner: { sizes: [[300, 250]] } },
params: {
placementId: 123
},
sizes: [
[300, 250]
],
src: 'client',
transactionId: '4781e6ac-93c4-42ba-86fe-ab5f278863cf'
};
it('should return true where required params found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
});
describe('buildRequests', function () {
const bidRequests = [
{
adUnitCode: 'adunit-code',
auctionId: '69e8fef8-5105-4a99-b011-d5669f3bc7f0',
bidId: '23beaa6af6cdde',
bidRequestsCount: 1,
bidder: 'ablida',
bidderRequestId: '14d2939272a26a',
bidderRequestsCount: 1,
bidderWinsCount: 0,
mediaTypes: { banner: { sizes: [[300, 250]] } },
params: {
placementId: 123
},
sizes: [
[300, 250]
],
src: 'client',
transactionId: '4781e6ac-93c4-42ba-86fe-ab5f278863cf'
}
];
const bidderRequests = {
refererInfo: {
canonicalUrl: '',
numIframes: 0,
reachedTop: true,
referer: 'http://example.com',
stack: ['http://example.com']
}
};
const request = spec.buildRequests(bidRequests, bidderRequests);
it('sends bid request via POST', function () {
expect(request[0].method).to.equal('POST');
});
});
describe('interpretResponse', function () {
const bidRequest = {
method: 'POST',
url: ENDPOINT_URL,
data: {
adapterVersion: 5,
bidId: '2b8c4de0116e54',
categories: undefined,
device: 'desktop',
gdprConsent: undefined,
jaySupported: true,
mediaTypes: { banner: { sizes: [[300, 250]] } },
placementId: 'testPlacementId',
width: 300,
height: 200,
referer: 'www.example.com'
}
};
const serverResponse = {
body: [{
ad: '<script>console.log("ad");</script>',
cpm: 1.00,
creativeId: '2b8c4de0116e54',
currency: 'EUR',
height: 250,
mediaType: 'banner',
meta: {},
netRevenue: true,
nurl: 'https://example.com/some-tracker',
originalCpm: '0.10',
originalCurrency: 'EUR',
requestId: '2b8c4de0116e54',
ttl: 3000,
width: 300
}]
};
it('should get the correct bid response', function () {
const expectedResponse = [{
ad: '<script>console.log("ad");</script>',
cpm: 1.00,
creativeId: '2b8c4de0116e54',
currency: 'EUR',
height: 250,
mediaType: 'banner',
meta: {},
netRevenue: true,
nurl: 'https://example.com/some-tracker',
originalCpm: '0.10',
originalCurrency: 'EUR',
requestId: '2b8c4de0116e54',
ttl: 3000,
width: 300
}];
const result = spec.interpretResponse(serverResponse, bidRequest[0]);
expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse));
});
});
describe('onBidWon', function() {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});
afterEach(function() {
utils.triggerPixel.restore();
});
it('Should not trigger pixel if bid does not contain nurl', function() {
spec.onBidWon({});
expect(utils.triggerPixel.callCount).to.equal(0);
});
it('Should trigger pixel if bid nurl', function() {
const nurl = 'https://bidder.ablida.net/win';
spec.onBidWon({ nurl });
expect(utils.triggerPixel.calledOnceWithExactly(nurl)).to.equal(true);
});
});
});