1 | import videojs from 'video.js';
|
2 | import '../../examples/basic-ad-plugin/example-plugin.js';
|
3 | import QUnit from 'qunit';
|
4 | import document from 'global/document';
|
5 |
|
6 | QUnit.module('Final Events With No Postroll', {
|
7 | beforeEach() {
|
8 | this.video = document.createElement('video');
|
9 |
|
10 | this.fixture = document.querySelector('#qunit-fixture');
|
11 | this.fixture.appendChild(this.video);
|
12 |
|
13 | this.player = videojs(this.video);
|
14 |
|
15 | this.player.exampleAds({
|
16 | adServerUrl: '/test/integration/lib/inventory.json',
|
17 | playPreroll: false,
|
18 | playMidroll: false,
|
19 | playPostroll: false
|
20 | });
|
21 |
|
22 | this.player.src({
|
23 | src: 'http://vjs.zencdn.net/v/oceans.webm',
|
24 | type: 'video/webm'
|
25 | });
|
26 |
|
27 |
|
28 | this.player.muted(true);
|
29 | },
|
30 |
|
31 | afterEach() {
|
32 | this.player.dispose();
|
33 | }
|
34 | });
|
35 |
|
36 | QUnit.test('final ended event with no postroll: just 1', function(assert) {
|
37 | const done = assert.async();
|
38 | let endedEvents = 0;
|
39 |
|
40 |
|
41 | this.player.ads.settings.postrollTimeout = 1;
|
42 |
|
43 | this.player.on('ended', () => {
|
44 | endedEvents++;
|
45 | });
|
46 |
|
47 | this.player.on(['error', 'aderror'], () => {
|
48 | assert.ok(false, 'no errors');
|
49 | done();
|
50 | });
|
51 |
|
52 | this.player.one('ended', () => {
|
53 |
|
54 | setTimeout(() => {
|
55 | assert.equal(endedEvents, 1, 'exactly one ended with no postroll');
|
56 | done();
|
57 | }, 1000);
|
58 | });
|
59 |
|
60 |
|
61 | this.player.one('playing', () => {
|
62 | this.player.currentTime(46);
|
63 | });
|
64 |
|
65 | this.player.ready(this.player.play);
|
66 |
|
67 | });
|