forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_spec.js
113 lines (105 loc) · 2.59 KB
/
video_spec.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
import { isValidVideoBid } from 'src/video.js';
describe('video.js', function () {
it('validates valid instream bids', function () {
const bid = {
adId: '456xyz',
vastUrl: 'http://www.example.com/vastUrl',
requestId: '123abc'
};
const bidRequests = [{
bids: [{
bidId: '123abc',
bidder: 'appnexus',
mediaTypes: {
video: { context: 'instream' }
}
}]
}];
const valid = isValidVideoBid(bid, bidRequests);
expect(valid).to.equal(true);
});
it('catches invalid instream bids', function () {
const bid = {
requestId: '123abc'
};
const bidRequests = [{
bids: [{
bidId: '123abc',
bidder: 'appnexus',
mediaTypes: {
video: { context: 'instream' }
}
}]
}];
const valid = isValidVideoBid(bid, bidRequests);
expect(valid).to.equal(false);
});
it('catches invalid bids when prebid-cache is disabled', function () {
const bidRequests = [{
bids: [{
bidder: 'vastOnlyVideoBidder',
mediaTypes: { video: {} },
}]
}];
const valid = isValidVideoBid({ vastXml: '<xml>vast</xml>' }, bidRequests);
expect(valid).to.equal(false);
});
it('validates valid outstream bids', function () {
const bid = {
requestId: '123abc',
renderer: {
url: 'render.url',
render: () => true,
}
};
const bidRequests = [{
bids: [{
bidId: '123abc',
bidder: 'appnexus',
mediaTypes: {
video: { context: 'outstream' }
}
}]
}];
const valid = isValidVideoBid(bid, bidRequests);
expect(valid).to.equal(true);
});
it('validates valid outstream bids with a publisher defined renderer', function () {
const bid = {
requestId: '123abc',
};
const bidRequests = [{
bids: [{
bidId: '123abc',
bidder: 'appnexus',
mediaTypes: {
video: {
context: 'outstream',
renderer: {
url: 'render.url',
render: () => true,
}
}
}
}]
}];
const valid = isValidVideoBid(bid, bidRequests);
expect(valid).to.equal(true);
});
it('catches invalid outstream bids', function () {
const bid = {
requestId: '123abc'
};
const bidRequests = [{
bids: [{
bidId: '123abc',
bidder: 'appnexus',
mediaTypes: {
video: { context: 'outstream' }
}
}]
}];
const valid = isValidVideoBid(bid, bidRequests);
expect(valid).to.equal(false);
});
});