UNPKG

1.62 kBJavaScriptView Raw
1import document from 'global/document';
2
3import QUnit from 'qunit';
4import sinon from 'sinon';
5import videojs from 'video.js';
6
7import plugin from '../src/plugin';
8
9const Player = videojs.getComponent('Player');
10
11QUnit.test('the environment is sane', function(assert) {
12 assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
13 assert.strictEqual(typeof sinon, 'object', 'sinon exists');
14 assert.strictEqual(typeof videojs, 'function', 'videojs exists');
15 assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
16});
17
18QUnit.module('videojs-dock', {
19
20 beforeEach() {
21 this.fixture = document.getElementById('qunit-fixture');
22 this.video = document.createElement('video');
23 this.fixture.appendChild(this.video);
24 this.player = videojs(this.video);
25
26 // Mock the environment's timers because certain things - particularly
27 // player readiness - are asynchronous in video.js 5.
28 this.clock = sinon.useFakeTimers();
29 },
30
31 afterEach() {
32
33 // The clock _must_ be restored before disposing the player; otherwise,
34 // certain timeout listeners that happen inside video.js may throw errors.
35 this.clock.restore();
36 this.player.dispose();
37 }
38});
39
40QUnit.test('registers itself with video.js', function(assert) {
41 assert.expect(2);
42
43 assert.strictEqual(
44 Player.prototype.dock,
45 plugin,
46 'videojs-dock plugin was registered'
47 );
48
49 this.player.dock();
50
51 // Tick the clock forward enough to trigger the player to be "ready".
52 this.clock.tick(1);
53
54 assert.ok(
55 this.player.hasClass('vjs-dock'),
56 'the plugin adds a class to the player'
57 );
58});