forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmaruBidAdapter_spec.js
More file actions
172 lines (154 loc) · 4.74 KB
/
admaruBidAdapter_spec.js
File metadata and controls
172 lines (154 loc) · 4.74 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { expect } from 'chai';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { spec } from '../../../modules/admaruBidAdapter.js';
const ENDPOINT = 'https://p1.admaru.net/AdCall';
describe('Admaru Adapter', function () {
const adapter = newBidder(spec);
describe('inherited functions', function () {
it('should exists and is a function', function () {
expect(adapter.callBids).to.exist.and.to.be.a('function');
});
});
describe('isBidRequestValidForBanner', () => {
const bid = {
'bidder': 'admaru',
'params': {
'pub_id': '1234',
'adspace_id': '1234'
},
'adUnitCode': 'adunit-code',
'mediaTypes': {
'banner': {
'sizes': [
[300, 250]
]
}
},
'sizes': [[300, 250]],
'bidId': '26e88c3c703e66',
'bidderRequestId': '1a8ff729f6c1a3',
'auctionId': 'cb65d954-ffe1-4f4a-8603-02b521c00333',
};
it('should return true when required params found', () => {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
it('should return false when required params are not passed', () => {
const invalidBid = Object.assign({}, bid);
delete invalidBid.params;
invalidBid.params = {
wrong: 'missing pub_id or adspace_id'
};
expect(spec.isBidRequestValid(invalidBid)).to.equal(false);
});
});
describe('buildRequestsForBanner', () => {
const bidRequests = [
{
'bidder': 'admaru',
'params': {
'pub_id': '1234',
'adspace_id': '1234'
},
'adUnitCode': 'adunit-code',
'mediaTypes': {
'banner': {
'sizes': [
[300, 250]
]
}
},
'sizes': [[300, 250]],
'bidId': '26e88c3c703e66',
'bidderRequestId': '1a8ff729f6c1a3',
'auctionId': 'cb65d954-ffe1-4f4a-8603-02b521c00333'
}
];
it('should add parameters to the tag', () => {
const request = spec.buildRequests(bidRequests);
const payload = request[0].data;
expect(payload.pub_id).to.equal('1234');
expect(payload.adspace_id).to.equal('1234');
// expect(payload.refererInfo).to.equal('{"referer": "https://www.admaru.com/test/admaru_prebid/icv_reminder/test.html","reachedTop": true,"numIframes": 1,"stack": ["https://www.admaru.com/test/admaru_prebid/icv_reminder/test.html","https://www.admaru.com/test/admaru_prebid/icv_reminder/test.html"]}');
// expect(payload.os).to.equal('windows');
// expect(payload.platform).to.equal('pc_web');
expect(payload.bidderRequestId).to.equal('1a8ff729f6c1a3');
expect(payload.bidId).to.equal('26e88c3c703e66');
});
it('sends bid request to ENDPOINT via GET', () => {
const request = spec.buildRequests(bidRequests);
expect(request[0].url).to.contain(ENDPOINT);
expect(request[0].method).to.equal('GET');
});
});
describe('interpretResponseForBanner', () => {
const bidRequests = [
{
'bidder': 'admaru',
'params': {
'pub_id': '1234',
'adspace_id': '1234'
},
'adUnitCode': 'adunit-code',
'mediaTypes': {
'banner': {
'sizes': [
[300, 250]
]
}
},
'sizes': [[300, 250]],
'bidId': '26e88c3c703e66',
'bidderRequestId': '1a8ff729f6c1a3',
'auctionId': 'cb65d954-ffe1-4f4a-8603-02b521c00333'
}
];
it('handles nobid responses', () => {
var request = spec.buildRequests(bidRequests);
const response = '';
const result = spec.interpretResponse(response, request[0]);
expect(result.length).to.equal(0);
});
});
describe('getUserSyncs()', () => {
it('should return iframe user sync if iframe sync is enabled', () => {
const syncs = spec.getUserSyncs(
{
pixelEnabled: true,
iframeEnabled: true,
},
null
);
expect(syncs).to.deep.equal([
{
type: 'iframe',
url: 'https://p2.admaru.net/UserSync/sync',
},
]);
});
it('should return image syncs if they are enabled and iframe is disabled', () => {
const syncs = spec.getUserSyncs(
{
pixelEnabled: true,
iframeEnabled: false,
},
null
);
expect(syncs).to.deep.equal([
{
type: 'image',
url: 'https://p2.admaru.net/UserSync/sync',
},
]);
});
it('should not return user syncs if syncs are disabled', () => {
const syncs = spec.getUserSyncs(
{
pixelEnabled: false,
iframeEnabled: false,
},
null
);
expect(syncs).to.deep.equal([]);
});
});
});