-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathundertone-htb-system-tests.js
133 lines (120 loc) · 3.11 KB
/
undertone-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
'use strict';
function getPartnerId() {
return 'UndertoneHtb';
}
function getStatsId() {
return 'UNDR';
}
function getCallbackType() {
return 'NONE';
}
function getArchitecture() {
return 'SRA';
}
function getConfig() {
return {
publisherId: '12345',
xSlots: {
1: {
sizes: [[300, 250]],
placementId: '1234'
},
2: {
sizes: [[300, 600]]
}
}
};
}
function getBidRequestRegex() {
return {
method: 'POST',
urlRegex: /hb\.undertone\.com\/hb.*/
};
}
function validateBidRequest(request) {
expect(request.query.pid).toBe('12345');
expect(request.query.domain).toBeDefined();
}
function getValidResponse(request, creative) {
var response = JSON.stringify([
{
ad: creative || '<div id="1"></div>',
publisherId: 12345,
bidRequestId: JSON.parse(request.body)['x-ut-hb-params'][0].bidRequestId,
adId: 15,
campaignId: 2,
height: 250,
width: 300,
ttl: 720,
currency: 'USD',
cpm: 2,
adaptor: 'indexexchange',
netRevenue: true
},
{
ad: creative || '<div id="1"></div>',
publisherId: 12345,
bidRequestId: JSON.parse(request.body)['x-ut-hb-params'][1].bidRequestId,
adId: 15,
campaignId: 2,
height: 600,
width: 300,
ttl: 720,
currency: 'USD',
cpm: 2,
adaptor: 'indexexchange',
netRevenue: true
}
]);
return response;
}
function validateTargeting(targetingMap) {
expect(targetingMap).toEqual(jasmine.objectContaining({
ix_undr_cpm: jasmine.arrayContaining(['300x250_200'])
}));
}
function getPassResponse(request) {
var response = JSON.stringify([
{
ad: null,
publisherId: 12345,
bidRequestId: JSON.parse(request.body)['x-ut-hb-params'][0].bidRequestId,
adId: 15,
campaignId: 2,
height: 250,
width: 300,
ttl: 720,
currency: 'USD',
cpm: 0,
adaptor: 'indexexchange',
netRevenue: true
},
{
ad: null,
publisherId: 12345,
bidRequestId: JSON.parse(request.body)['x-ut-hb-params'][1].bidRequestId,
adId: 15,
campaignId: 2,
height: 600,
width: 300,
ttl: 720,
currency: 'USD',
cpm: 0,
adaptor: 'indexexchange',
netRevenue: true
}
]);
return response;
}
module.exports = {
getPartnerId: getPartnerId,
getStatsId: getStatsId,
getCallbackType: getCallbackType,
getArchitecture: getArchitecture,
getConfig: getConfig,
getBidRequestRegex: getBidRequestRegex,
validateBidRequest: validateBidRequest,
getValidResponse: getValidResponse,
validateTargeting: validateTargeting,
getPassResponse: getPassResponse
};