mirror of
https://github.com/iv-org/videojs-vtt-thumbnails.git
synced 2025-08-12 08:20:32 -04:00
Initial commit
This commit is contained in:
commit
f0a97f8e13
23 changed files with 1020 additions and 0 deletions
19
test/index.html
Normal file
19
test/index.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>videojs-vtt-thumbnails Unit Tests</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../node_modules/video.js/dist/video-js.css">
|
||||
<link href="../dist/videojs-vtt-thumbnails.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
|
||||
<script src="../node_modules/sinon/pkg/sinon.js"></script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/video.js/dist/video.js"></script>
|
||||
<script src="../test/dist/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
43
test/karma.conf.js
Normal file
43
test/karma.conf.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
module.exports = function(config) {
|
||||
var detectBrowsers = {
|
||||
enabled: false,
|
||||
usePhantomJS: false
|
||||
};
|
||||
|
||||
// On Travis CI, we can only run in Firefox and Chrome; so, enforce that.
|
||||
if (process.env.TRAVIS) {
|
||||
config.browsers = ['Firefox', 'travisChrome'];
|
||||
}
|
||||
|
||||
// If no browsers are specified, we enable `karma-detect-browsers`
|
||||
// this will detect all browsers that are available for testing
|
||||
if (!config.browsers.length) {
|
||||
detectBrowsers.enabled = true;
|
||||
}
|
||||
|
||||
config.set({
|
||||
basePath: '..',
|
||||
frameworks: ['qunit', 'detectBrowsers'],
|
||||
files: [
|
||||
'node_modules/video.js/dist/video-js.css',
|
||||
'dist/videojs-vtt-thumbnails.css',
|
||||
|
||||
'node_modules/sinon/pkg/sinon.js',
|
||||
'node_modules/video.js/dist/video.js',
|
||||
'test/dist/bundle.js'
|
||||
],
|
||||
customLaunchers: {
|
||||
travisChrome: {
|
||||
base: 'Chrome',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
detectBrowsers: detectBrowsers,
|
||||
reporters: ['dots'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
autoWatch: false,
|
||||
singleRun: true,
|
||||
concurrency: Infinity
|
||||
});
|
||||
};
|
58
test/plugin.test.js
Normal file
58
test/plugin.test.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
import document from 'global/document';
|
||||
|
||||
import QUnit from 'qunit';
|
||||
import sinon from 'sinon';
|
||||
import videojs from 'video.js';
|
||||
|
||||
import plugin from '../src/plugin';
|
||||
|
||||
const Player = videojs.getComponent('Player');
|
||||
|
||||
QUnit.test('the environment is sane', function(assert) {
|
||||
assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
|
||||
assert.strictEqual(typeof sinon, 'object', 'sinon exists');
|
||||
assert.strictEqual(typeof videojs, 'function', 'videojs exists');
|
||||
assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
|
||||
});
|
||||
|
||||
QUnit.module('videojs-vtt-thumbnails', {
|
||||
|
||||
beforeEach() {
|
||||
|
||||
// Mock the environment's timers because certain things - particularly
|
||||
// player readiness - are asynchronous in video.js 5. This MUST come
|
||||
// before any player is created; otherwise, timers could get created
|
||||
// with the actual timer methods!
|
||||
this.clock = sinon.useFakeTimers();
|
||||
|
||||
this.fixture = document.getElementById('qunit-fixture');
|
||||
this.video = document.createElement('video');
|
||||
this.fixture.appendChild(this.video);
|
||||
this.player = videojs(this.video);
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
this.player.dispose();
|
||||
this.clock.restore();
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('registers itself with video.js', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
assert.strictEqual(
|
||||
typeof Player.prototype.vttThumbnails,
|
||||
'function',
|
||||
'videojs-vtt-thumbnails plugin was registered'
|
||||
);
|
||||
|
||||
this.player.vttThumbnails();
|
||||
|
||||
// Tick the clock forward enough to trigger the player to be "ready".
|
||||
this.clock.tick(2);
|
||||
|
||||
assert.ok(
|
||||
this.player.hasClass('vjs-vtt-thumbnails'),
|
||||
'the plugin adds a class to the player'
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue