plugin.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import document from 'global/document';
  2. import QUnit from 'qunit';
  3. import sinon from 'sinon';
  4. import videojs from 'video.js';
  5. import plugin from '../src/plugin';
  6. const Player = videojs.getComponent('Player');
  7. QUnit.test('the environment is sane', function(assert) {
  8. assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
  9. assert.strictEqual(typeof sinon, 'object', 'sinon exists');
  10. assert.strictEqual(typeof videojs, 'function', 'videojs exists');
  11. assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
  12. });
  13. QUnit.module('videojs-contrib-quality-levels', {
  14. beforeEach() {
  15. // Mock the environment's timers because certain things - particularly
  16. // player readiness - are asynchronous in video.js 5. This MUST come
  17. // before any player is created; otherwise, timers could get created
  18. // with the actual timer methods!
  19. this.clock = sinon.useFakeTimers();
  20. this.fixture = document.getElementById('qunit-fixture');
  21. this.video = document.createElement('video');
  22. this.fixture.appendChild(this.video);
  23. this.player = videojs(this.video);
  24. },
  25. afterEach() {
  26. this.player.dispose();
  27. this.clock.restore();
  28. }
  29. });
  30. QUnit.test('registers itself with video.js', function(assert) {
  31. assert.strictEqual(
  32. typeof Player.prototype.qualityLevels,
  33. 'function',
  34. 'videojs-contrib-quality-levels plugin was registered'
  35. );
  36. });