2015-05-04 01:12:38 +02:00
|
|
|
import videojs from '../../src/js/video.js';
|
|
|
|
import TestHelpers from './test-helpers.js';
|
2015-03-26 06:43:41 +02:00
|
|
|
import Player from '../../src/js/player.js';
|
|
|
|
import Options from '../../src/js/options.js';
|
|
|
|
import document from 'global/document';
|
|
|
|
|
2015-05-04 01:12:38 +02:00
|
|
|
q.module('video.js');
|
2013-01-11 00:06:12 +03:00
|
|
|
|
|
|
|
test('should create a video tag and have access children in old IE', function(){
|
|
|
|
var fixture = document.getElementById('qunit-fixture');
|
|
|
|
|
2013-02-09 01:18:49 +03:00
|
|
|
fixture.innerHTML += '<video id="test_vid_id"><source type="video/mp4"></video>';
|
2013-01-11 00:06:12 +03:00
|
|
|
|
2013-01-26 04:36:40 +03:00
|
|
|
var vid = document.getElementById('test_vid_id');
|
2013-01-11 00:06:12 +03:00
|
|
|
|
|
|
|
ok(vid.childNodes.length === 1);
|
|
|
|
ok(vid.childNodes[0].getAttribute('type') === 'video/mp4');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should return a video player instance', function(){
|
|
|
|
var fixture = document.getElementById('qunit-fixture');
|
2013-02-09 01:18:49 +03:00
|
|
|
fixture.innerHTML += '<video id="test_vid_id"></video><video id="test_vid_id2"></video>';
|
2013-01-11 00:06:12 +03:00
|
|
|
|
|
|
|
var player = videojs('test_vid_id');
|
|
|
|
ok(player, 'created player from tag');
|
|
|
|
ok(player.id() === 'test_vid_id');
|
2015-03-26 06:43:41 +02:00
|
|
|
ok(Player.players['test_vid_id'] === player, 'added player to global reference');
|
2013-01-11 00:06:12 +03:00
|
|
|
|
|
|
|
var playerAgain = videojs('test_vid_id');
|
|
|
|
ok(player === playerAgain, 'did not create a second player from same tag');
|
|
|
|
|
|
|
|
var tag2 = document.getElementById('test_vid_id2');
|
|
|
|
var player2 = videojs(tag2);
|
|
|
|
ok(player2.id() === 'test_vid_id2', 'created player from element');
|
|
|
|
});
|
2014-08-18 20:43:30 +03:00
|
|
|
|
|
|
|
test('should add the value to the languages object', function() {
|
|
|
|
var code, data, result;
|
|
|
|
|
|
|
|
code = 'es';
|
|
|
|
data = {'Hello': 'Hola'};
|
2015-03-26 06:43:41 +02:00
|
|
|
result = videojs.addLanguage(code, data);
|
2014-08-18 20:43:30 +03:00
|
|
|
|
2015-03-26 06:43:41 +02:00
|
|
|
ok(Options['languages'][code], 'should exist');
|
|
|
|
equal(Options['languages'][code], data, 'should match');
|
|
|
|
deepEqual(result[code], Options['languages'][code], 'should also match');
|
2015-05-04 01:12:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should expose plugin registry function', function() {
|
|
|
|
var pluginName, pluginFunction, player;
|
|
|
|
|
|
|
|
pluginName = 'foo';
|
|
|
|
pluginFunction = function(options) {
|
|
|
|
console.log(this);
|
|
|
|
};
|
|
|
|
|
|
|
|
ok(videojs.plugin, 'should exist');
|
|
|
|
|
|
|
|
videojs.plugin(pluginName, pluginFunction);
|
|
|
|
|
|
|
|
player = TestHelpers.makePlayer();
|
|
|
|
|
|
|
|
ok(player.foo, 'should exist');
|
|
|
|
equal(player.foo, pluginFunction, 'should be equal');
|
|
|
|
});
|