UNPKG

1.68 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-max-quality-selector', {
19
20 beforeEach() {
21
22 // Mock the environment's timers because certain things - particularly
23 // player readiness - are asynchronous in video.js 5. This MUST come
24 // before any player is created; otherwise, timers could get created
25 // with the actual timer methods!
26 this.clock = sinon.useFakeTimers();
27
28 this.fixture = document.getElementById('qunit-fixture');
29 this.video = document.createElement('video');
30 this.fixture.appendChild(this.video);
31 this.player = videojs(this.video);
32 },
33
34 afterEach() {
35 this.player.dispose();
36 this.clock.restore();
37 }
38});
39
40QUnit.test('registers itself with video.js', function(assert) {
41 assert.expect(2);
42
43 assert.strictEqual(
44 typeof Player.prototype.maxQualitySelector,
45 'function',
46 'videojs-max-quality-selector plugin was registered'
47 );
48
49 this.player.maxQualitySelector();
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-max-quality-selector'),
56 'the plugin adds a class to the player'
57 );
58});