forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_spec.js
103 lines (94 loc) · 2.56 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
import { isValidVideoBid } from 'src/video.js';
import {hook} from '../../src/hook.js';
import {stubAuctionIndex} from '../helpers/indexStub.js';
describe('video.js', function () {
before(() => {
hook.ready();
});
it('validates valid instream bids', function () {
const bid = {
adId: '456xyz',
vastUrl: 'http://www.example.com/vastUrl',
transactionId: 'au'
};
const adUnits = [{
transactionId: 'au',
mediaTypes: {
video: {context: 'instream'}
}
}];
const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(true);
});
it('catches invalid instream bids', function () {
const bid = {
transactionId: 'au'
};
const adUnits = [{
transactionId: 'au',
mediaTypes: {
video: {context: 'instream'}
}
}];
const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(false);
});
it('catches invalid bids when prebid-cache is disabled', function () {
const adUnits = [{
transactionId: 'au',
bidder: 'vastOnlyVideoBidder',
mediaTypes: {video: {}},
}];
const valid = isValidVideoBid({ transactionId: 'au', vastXml: '<xml>vast</xml>' }, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(false);
});
it('validates valid outstream bids', function () {
const bid = {
transactionId: 'au',
renderer: {
url: 'render.url',
render: () => true,
}
};
const adUnits = [{
transactionId: 'au',
mediaTypes: {
video: {context: 'outstream'}
}
}];
const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(true);
});
it('validates valid outstream bids with a publisher defined renderer', function () {
const bid = {
transactionId: 'au',
};
const adUnits = [{
transactionId: 'au',
mediaTypes: {
video: {
context: 'outstream',
}
},
renderer: {
url: 'render.url',
render: () => true,
}
}];
const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(true);
});
it('catches invalid outstream bids', function () {
const bid = {
transactionId: 'au',
};
const adUnits = [{
transactionId: 'au',
mediaTypes: {
video: {context: 'outstream'}
}
}];
const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})});
expect(valid).to.equal(false);
});
});