forked from indexexchange/rhythm-one-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrhythm-one-htb-system-tests.js
138 lines (125 loc) · 3.48 KB
/
rhythm-one-htb-system-tests.js
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
'use strict';
function getPartnerId() {
return 'RhythmOneHtb';
}
function getStatsId() {
return 'RONE';
}
function getBidRequestRegex() {
return {
method: 'GET',
urlRegex: /^http?:|https?:\/\/tag\.1rx\.io\/rmp.*/
};
}
function getCallbackType() {
return 'NONE';
}
function getArchitecture() {
return 'SRA';
}
function getConfig() {
return {
xSlots: {
1: {
placementId: '471141',
zone: 'autoqa',
path: 'mvo',
imp: '1',
adType: 'banner',
floor: '100',
sizes: [[300, 250]]
},
2: {
placementId: '471141',
zone: 'autoqa',
path: 'mvo',
imp: '2',
floor: '100',
adType: 'banner',
sizes: [[300, 250]]
}
}
};
}
function validateBidRequest(request) {
expect(request.host).toBe('tag.1rx.io');
expect(request.pathname).toContain('mvo');
expect(request.query.z).toBeDefined();
expect(request.query.imp).toBeDefined();
expect(request.query.w).toBeDefined();
expect(request.query.h).toBeDefined();
expect(request.query.t).toBeDefined();
}
function getValidResponse(request, creative) {
var response = {
cur: 'USD',
id: '567841330',
seatbid: [
{
bid: [
{
adid: '1487603',
adm: creative,
adomain: ['www.rhythmone.com'],
ext: {
advbrand: 'R1',
advbrandid: '25661',
pricelevel: '200'
},
id: 567841330,
impid: '1',
price: 200,
h: '250',
w: '300'
},
{
adid: '1487603',
adm: creative,
adomain: ['www.rhythmone.com'],
ext: {
advbrand: 'R1',
advbrandid: '25661',
pricelevel: '100'
},
id: 567841330,
impid: '2',
price: 200,
h: '250',
w: '300'
}
],
seat: '470013'
}
]
};
return JSON.stringify(response);
}
function getPassResponse() {
var response = {
id: 'Test',
seatbid: [
{
bid: []
}
]
};
return JSON.stringify(response);
}
function validateTargeting(targetingMap) {
expect(targetingMap).toEqual(jasmine.objectContaining({
ix_rone_cpm: jasmine.arrayContaining(['300x250_200', '300x250_200']),
ix_rone_id: jasmine.arrayContaining([jasmine.any(String), jasmine.any(String)])
}));
}
module.exports = {
getPartnerId: getPartnerId,
getStatsId: getStatsId,
getBidRequestRegex: getBidRequestRegex,
getCallbackType: getCallbackType,
getArchitecture: getArchitecture,
getConfig: getConfig,
validateBidRequest: validateBidRequest,
getValidResponse: getValidResponse,
validateTargeting: validateTargeting,
getPassResponse: getPassResponse
};