-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
145 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Video.js Transcript Sub Modules</title> | ||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script> | ||
<script> | ||
test('the environment is sane', function() { | ||
ok(true, 'everything is swell'); | ||
}); | ||
</script> | ||
<script src="../node_modules/video.js/dist/video-js/video.js"></script> | ||
<script src="../src/options.js"></script> | ||
<script src="../src/events.js"></script> | ||
<script src="../src/tracklist.js"></script> | ||
<script src="../src/scroller.js"></script> | ||
<script src="../src/widget.js"></script> | ||
<script src="modules.test.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/*! videojs-transcript - v0.0.0 - 2014-9-8 | ||
* Copyright (c) 2014 Matthew Walsh | ||
* Licensed under the MIT license. */ | ||
(function (window, videojs, qunit) { | ||
'use strict'; | ||
|
||
var realIsHtmlSupported, | ||
player, | ||
|
||
// local QUnit aliases | ||
// http://api.qunitjs.com/ | ||
|
||
// module(name, {[setup][ ,teardown]}) | ||
module = qunit.module, | ||
// test(name, callback) | ||
test = qunit.test, | ||
// ok(value, [message]) | ||
ok = qunit.ok, | ||
// equal(actual, expected, [message]) | ||
equal = qunit.equal, | ||
// strictEqual(actual, expected, [message]) | ||
strictEqual = qunit.strictEqual, | ||
// deepEqual(actual, expected, [message]) | ||
deepEqual = qunit.deepEqual, | ||
// notEqual(actual, expected, [message]) | ||
notEqual = qunit.notEqual, | ||
// throws(block, [expected], [message]) | ||
throws = qunit.throws; | ||
|
||
/******************** | ||
* test events.js | ||
********************/ | ||
module('events', { | ||
setup: function() { | ||
// force HTML support so the tests run in a reasonable | ||
// environment under phantomjs | ||
realIsHtmlSupported = videojs.Html5.isSupported; | ||
videojs.Html5.isSupported = function () { | ||
return true; | ||
}; | ||
|
||
// create a video element | ||
var video = document.createElement('video'); | ||
document.querySelector('#qunit-fixture').appendChild(video); | ||
|
||
// create a video.js player | ||
player = videojs(video); | ||
|
||
my.player = player; | ||
}, | ||
teardown: function() { | ||
videojs.Html5.isSupported = realIsHtmlSupported; | ||
} | ||
}); | ||
|
||
test('Register and trigger event', function(assert) { | ||
expect(1); | ||
eventEmitter.on(this, 'test', function() { | ||
assert.ok(true, 'Event was triggered.'); | ||
}); | ||
eventEmitter.trigger(this, 'test'); | ||
}); | ||
|
||
/******************** | ||
* test tracklist.js | ||
********************/ | ||
module('tracklist', { | ||
setup: function() { | ||
// force HTML support so the tests run in a reasonable | ||
// environment under phantomjs | ||
realIsHtmlSupported = videojs.Html5.isSupported; | ||
videojs.Html5.isSupported = function () { | ||
return true; | ||
}; | ||
|
||
// create a video element | ||
var video = document.createElement('video'); | ||
video.setAttribute('id', 'test-video'); | ||
document.querySelector('#qunit-fixture').appendChild(video); | ||
|
||
var track = document.createElement('track'); | ||
track.setAttribute('kind', 'captions'); | ||
track.setAttribute('src', '../captions/captions.en.srt'); | ||
track.setAttribute('srclang', 'en'); | ||
track.setAttribute('label', 'English'); | ||
video.appendChild(track); | ||
|
||
var track2 = document.createElement('track'); | ||
track2.setAttribute('kind', 'subtitles'); | ||
track2.setAttribute('src', '../captions/captions.sv.srt'); | ||
track2.setAttribute('srclang', 'sv'); | ||
track2.setAttribute('label', 'Swedish'); | ||
video.appendChild(track2); | ||
|
||
// create a video.js player | ||
player = videojs(video); | ||
|
||
my.player = player; | ||
}, | ||
teardown: function() { | ||
videojs.Html5.isSupported = realIsHtmlSupported; | ||
} | ||
}); | ||
|
||
test('getTracks() returns list of tracks.', function(assert) { | ||
assert.equal(trackList.get().length, videojs.players['test-video'].textTracks().length, 'Tracklist length is correct'); | ||
}); | ||
|
||
test('active() returns the default track.', function(assert) { | ||
var tracks = trackList.get(); | ||
assert.equal(trackList.active(tracks).label(), 'English', 'Active track is defined'); | ||
}); | ||
|
||
test('active() returns active track after track change.', function(assert) { | ||
var tracks = trackList.get(); | ||
videojs.players['test-video'].textTracks()[1].show(); | ||
assert.equal(trackList.active(tracks).label(), 'Swedish', 'Active track returns current track after track change.'); | ||
}); | ||
|
||
}(window, window.videojs, window.QUnit)); |