forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmediaBidAdapter_spec.js
More file actions
130 lines (124 loc) · 3.35 KB
/
admediaBidAdapter_spec.js
File metadata and controls
130 lines (124 loc) · 3.35 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 { assert, expect } from 'chai';
import { spec } from 'modules/admediaBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import * as utils from 'src/utils.js';
const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/';
describe('admediaBidAdapter', function () {
const adapter = newBidder(spec);
describe('isBidRequestValid', function () {
const bid = {
adUnitCode: 'adunit-code',
bidder: 'admedia',
bidId: 'g7ghhs78',
mediaTypes: { banner: { sizes: [[300, 250]] } },
params: {
placementId: '782332',
aid: '86858',
},
refererInfo: {
page: 'https://test.com'
}
};
it('should return true where required params found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
});
describe('buildRequests', function () {
const bidRequests = [
{
adUnitCode: 'adunit-code',
bidder: 'admedia',
bidId: 'g7ghhs78',
mediaTypes: { banner: { sizes: [[300, 250]] } },
params: {
placementId: '782332',
aid: '86858'
},
refererInfo: {
page: 'https://test.com'
}
}
];
const bidderRequests = {
refererInfo: {
page: 'https://test.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: {
'id': '782332',
'aid': '86858',
'tags': [
{
'sizes': [
'300x250'
],
'id': '782332',
'aid': '86858'
}
],
'bidId': '2556388472b168',
'referer': 'https%3A%2F%test.com'
}
};
const serverResponse = {
body:
{
'tags': [
{
'requestId': '2b8bf2ac497ae',
'ad': "<img src='https://dummyimage.com/300x250/000150/fff.jpg&text=Admedia'>",
'width': 300,
'height': 250,
'cpm': 0.71,
'currency': 'USD',
'ttl': 200,
'creativeId': 128,
'netRevenue': true,
'meta': {
'advertiserDomains': [
'https://www.test.com'
]
}
}
]
}
};
it('should get the correct bid response', function () {
let expectedResponse =
{
'tags': [
{
'requestId': '2b8bf2ac497ae',
'ad': "<img src='https://dummyimage.com/300x250/000150/fff.jpg&text=Admedia'>",
'width': 300,
'height': 250,
'cpm': 0.71,
'currency': 'USD',
'ttl': 200,
'creativeId': 128,
'netRevenue': true,
'meta': {
'advertiserDomains': [
'https://www.test.com'
]
}
}
]
}
let result = spec.interpretResponse(serverResponse, bidRequest);
expect(result).to.be.an('array').that.is.not.empty;
expect(Object.keys(result[0])).to.have.members(
Object.keys(expectedResponse.tags[0])
);
});
});
});