diff --git a/src/events.js b/src/events.js
index 94a8d5d..7deeff0 100644
--- a/src/events.js
+++ b/src/events.js
@@ -18,14 +18,5 @@ var eventEmitter = {
h[2].apply();
}
});
- },
- delegate: function (obj) {
- obj.on = function (event, callback) {
- eventEmitter.on(obj, event, callback);
- };
- obj.trigger = function (obj) {
- eventEmitter.trigget(obj, event);
- };
- return obj;
}
};
diff --git a/test/modules.html b/test/modules.html
new file mode 100644
index 0000000..f4a41dc
--- /dev/null
+++ b/test/modules.html
@@ -0,0 +1,25 @@
+
+
+
+
+ Video.js Transcript Sub Modules
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/modules.test.js b/test/modules.test.js
new file mode 100644
index 0000000..7de3e32
--- /dev/null
+++ b/test/modules.test.js
@@ -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));