forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvangelistsBidAdapter_spec.js
More file actions
executable file
·118 lines (103 loc) · 7.51 KB
/
advangelistsBidAdapter_spec.js
File metadata and controls
executable file
·118 lines (103 loc) · 7.51 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
import { expect } from 'chai';
import { spec } from 'modules/advangelistsBidAdapter';
import { BANNER, VIDEO } from 'src/mediaTypes';
describe('advangelistsBidAdapter', function () {
let bidRequests;
let bidRequestsVid;
beforeEach(function () {
bidRequests = [{ 'bidder': 'advangelists', 'params': { 'pubid': '0cf8d6d643e13d86a5b6374148a4afac', 'placement': 1234 }, 'crumbs': { 'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449' }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250]] } }, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': 'f72931e6-2b0e-4e37-a2bc-1ea912141f81', 'sizes': [[300, 250]], 'bidId': '2aa73f571eaf29', 'bidderRequestId': '1bac84515a7af3', 'auctionId': '5dbc60fa-1aa1-41ce-9092-e6bbd4d478f7', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com' }];
bidRequestsVid = [{ 'bidder': 'advangelists', 'params': { 'pubid': '8537f00948fc37cc03c5f0f88e198a76', 'placement': 1234 }, 'crumbs': { 'pubcid': '979fde13-c71e-4ac2-98b7-28c90f99b449' }, 'mediaTypes': { 'video': { 'playerSize': [[320, 480]], 'context': 'instream', 'skip': 1, 'mimes': ['video/mp4', 'application/javascript'], 'playbackmethod': [2, 6], 'maxduration': 30 } }, 'adUnitCode': 'video1', 'transactionId': '8b060952-93f7-4863-af44-bb8796b97c42', 'sizes': [], 'bidId': '25c6ab92aa0e81', 'bidderRequestId': '1d420b73a013fc', 'auctionId': '9a69741c-34fb-474c-83e1-cfa003aaee17', 'src': 'client', 'bidRequestsCount': 1, 'pageurl': 'http://google.com' }];
});
describe('spec.isBidRequestValid', function () {
it('should return true when the required params are passed for banner', function () {
const bidRequest = bidRequests[0];
expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
});
it('should return true when the required params are passed for video', function () {
const bidRequests = bidRequestsVid[0];
expect(spec.isBidRequestValid(bidRequests)).to.equal(true);
});
it('should return false when no pub id params are passed', function () {
const bidRequest = bidRequests[0];
bidRequest.params.pubid = '';
expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
});
it('should return false when no placement params are passed', function () {
const bidRequest = bidRequests[0];
bidRequest.params.placement = '';
expect(spec.isBidRequestValid(bidRequest)).to.equal(false);
});
it('should return false when a bid request is not passed', function () {
expect(spec.isBidRequestValid()).to.equal(false);
expect(spec.isBidRequestValid({})).to.equal(false);
});
});
describe('spec.buildRequests', function () {
it('should create a POST request for each bid', function () {
const bidRequest = bidRequests[0];
const requests = spec.buildRequests([bidRequest], { timeout: 1000 });
expect(requests[0].method).to.equal('POST');
});
it('should create a POST request for each bid in video request', function () {
const bidRequest = bidRequestsVid[0];
const requests = spec.buildRequests([bidRequest], { timeout: 1000 });
expect(requests[0].method).to.equal('POST');
});
it('should have domain in request', function () {
const bidRequest = bidRequests[0];
const requests = spec.buildRequests([bidRequest], { timeout: 1000 });
expect(requests[0].data.site.domain).to.have.length.above(0);
});
});
describe('spec.interpretResponse', function () {
describe('for banner bids', function () {
it('should return valid video bid responses', function () {
const _mediaTypes = VIDEO;
const advangelistsbidreqVid = { 'bidRequest': { 'mediaTypes': { 'video': { 'w': 320, 'h': 480 } } } };
const serverResponseVid = { 'cur': 'USD', 'id': '25c6ab92aa0e81', 'seatbid': [{ 'seat': '3', 'bid': [{ 'crid': '1855', 'h': 480, 'protocol': 2, 'nurl': 'http://nep.advangelists.com/xp/evt?pp=1MO1wiaMhhq7wLRzZZwwwPkJxxKpYEnM5k5MH4qSGm1HR8rp3Nl7vDocvzZzSAvE4pnREL9mQ1kf5PDjk6E8em6DOk7vVrYUH1TYQyqCucd58PFpJNN7h30RXKHHFg3XaLuQ3PKfMuI1qZATBJ6WHcu875y0hqRdiewn0J4JsCYF53M27uwmcV0HnQxARQZZ72mPqrW95U6wgkZljziwKrICM3aBV07TU6YK5R5AyzJRuD6mtrQ2xtHlQ3jXVYKE5bvWFiUQd90t0jOGhPtYBNoOfP7uQ4ZZj4pyucxbr96orHe9PSOn9UpCSWArdx7s8lOfDpwOvbMuyGxynbStDWm38sDgd4bMHnIt762m5VMDNJfiUyX0vWzp05OsufJDVEaWhAM62i40lQZo7mWP4ipoOWLkmlaAzFIMsTcNaHAHiKKqGEOZLkCEhFNM0SLcvgN2HFRULOOIZvusq7TydOKxuXgCS91dLUDxDDDFUK83BFKlMkTxnCzkLbIR1bd9GKcr1TRryOrulyvRWAKAIhEsUzsc5QWFUhmI2dZ1eqnBQJ0c89TaPcnoaP2WipF68UgyiOstf2CBy0M34858tC5PmuQwQYwXscg6zyqDwR0i9MzGH4FkTyU5yeOlPcsA0ht6UcoCdFpHpumDrLUwAaxwGk1Nj8S6YlYYT5wNuTifDGbg22QKXzZBkUARiyVvgPn9nRtXnrd7WmiMYq596rya9RQj7LC0auQW8bHVQLEe49shsZDnAwZTWr4QuYKqgRGZcXteG7RVJe0ryBZezOq11ha9C0Lv0siNVBahOXE35Wzoq4c4BDaGpqvhaKN7pjeWLGlQR04ufWekwxiMWAvjmfgAfexBJ7HfbYNZpq__', 'adid': '61_1855', 'adomain': ['chevrolet.com'], 'price': 2, 'w': 320, 'iurl': 'https://daf37cpxaja7f.cloudfront.net/c61/creative_url_14922301369663_1.png', 'cat': ['IAB2'], 'id': '7f570b40-aca1-4806-8ea8-818ea679c82b_0', 'attr': [], 'impid': '0', 'cid': '61' }] }], 'bidid': '7f570b40-aca1-4806-8ea8-818ea679c82b' };
const bidResponseVid = spec.interpretResponse({ body: serverResponseVid }, advangelistsbidreqVid);
delete bidResponseVid['vastUrl'];
delete bidResponseVid['ad'];
expect(bidResponseVid).to.deep.equal({
requestId: bidRequestsVid[0].bidId,
creativeId: serverResponseVid.seatbid[0].bid[0].crid,
cpm: serverResponseVid.seatbid[0].bid[0].price,
width: serverResponseVid.seatbid[0].bid[0].w,
height: serverResponseVid.seatbid[0].bid[0].h,
mediaType: 'video',
meta: { 'advertiserDomains': serverResponseVid.seatbid[0].bid[0].adomain },
currency: 'USD',
netRevenue: true,
ttl: 60
});
});
it('should return valid banner bid responses', function () {
const advangelistsbidreq = { bids: {} };
bidRequests.forEach(bid => {
const _mediaTypes = (bid.mediaTypes && bid.mediaTypes.video ? VIDEO : BANNER);
advangelistsbidreq.bids[bid.bidId] = {
mediaTypes: _mediaTypes,
w: _mediaTypes === BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][0] : bid.mediaTypes[_mediaTypes].playerSize[0],
h: _mediaTypes === BANNER ? bid.mediaTypes[_mediaTypes].sizes[0][1] : bid.mediaTypes[_mediaTypes].playerSize[1]
};
});
const serverResponse = { 'id': '2aa73f571eaf29', 'seatbid': [{ 'bid': [{ 'id': '2c5e8a1a84522d', 'impid': '2c5e8a1a84522d', 'price': 0.81, 'adid': 'abcde-12345', 'nurl': '', 'adm': '<div><img src=\'http://cdnin.bnmla.com/0b1c6e85e9376e3092df8c9fc8ab9095.gif\' width=350 height=250 /></div>', 'iurl': '', 'cid': 'campaign1', 'crid': 'abcde-12345', 'adomain': ['chevrolet.com'], 'w': 300, 'h': 250 }], 'seat': '19513bcfca8006' }], 'bidid': '19513bcfca8006', 'cur': 'USD', 'w': 300, 'h': 250 };
const bidResponse = spec.interpretResponse({ body: serverResponse }, advangelistsbidreq);
expect(bidResponse).to.deep.equal({
requestId: bidRequests[0].bidId,
ad: serverResponse.seatbid[0].bid[0].adm,
bidderCode: 'advangelists',
creativeId: serverResponse.seatbid[0].bid[0].crid,
cpm: serverResponse.seatbid[0].bid[0].price,
width: serverResponse.seatbid[0].bid[0].w,
height: serverResponse.seatbid[0].bid[0].h,
mediaType: 'banner',
meta: { 'advertiserDomains': serverResponse.seatbid[0].bid[0].adomain },
currency: 'USD',
netRevenue: true,
ttl: 60
});
});
});
});
});