mirror of
https://github.com/videojs/video.js.git
synced 2025-02-02 11:34:50 +02:00
Merge pull request #360 from mente/minified
correctly expose ready and dispose in minified version
This commit is contained in:
commit
78a74536e5
@ -37,7 +37,7 @@ module.exports = function(grunt) {
|
||||
dest: 'build/files/minified.video.js'
|
||||
},
|
||||
tests: {
|
||||
src: ['build/files/combined.video.js', 'test/unit/*.js'],
|
||||
src: ['build/files/combined.video.js', 'test/unit/*.js', '!test/unit/api.js'],
|
||||
externs: ['src/js/media.flash.externs.js', 'test/qunit/qunit-externs.js'],
|
||||
dest: 'build/files/test.minified.video.js'
|
||||
}
|
||||
@ -45,7 +45,8 @@ module.exports = function(grunt) {
|
||||
dist: {},
|
||||
qunit: {
|
||||
source: ['test/index.html'],
|
||||
minified: ['test/minified.html']
|
||||
minified: ['test/minified.html'],
|
||||
minified_api: ['test/minified-api.html']
|
||||
},
|
||||
watch: {
|
||||
files: [ 'src/**/*.js', 'test/unit/*.js' ],
|
||||
@ -64,7 +65,7 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('default', ['jshint', 'build', 'minify', 'dist']);
|
||||
// Development watch task
|
||||
grunt.registerTask('dev', ['jshint', 'build', 'qunit:source']);
|
||||
grunt.registerTask('test', ['jshint', 'build', 'minify:tests', 'qunit']);
|
||||
grunt.registerTask('test', ['jshint', 'build', 'minify', 'qunit']);
|
||||
|
||||
var fs = require('fs'),
|
||||
gzip = require('zlib').gzip;
|
||||
|
@ -48,8 +48,10 @@ goog.exportProperty(vjs.Component.prototype, 'hide', vjs.Component.prototype.hid
|
||||
goog.exportProperty(vjs.Component.prototype, 'width', vjs.Component.prototype.width);
|
||||
goog.exportProperty(vjs.Component.prototype, 'height', vjs.Component.prototype.height);
|
||||
goog.exportProperty(vjs.Component.prototype, 'dimensions', vjs.Component.prototype.dimensions);
|
||||
goog.exportProperty(vjs.Component.prototype, 'ready', vjs.Component.prototype.ready);
|
||||
|
||||
goog.exportSymbol('videojs.Player', vjs.Player);
|
||||
goog.exportProperty(vjs.Player.prototype, 'dispose', vjs.Player.prototype.dispose);
|
||||
|
||||
goog.exportSymbol('videojs.MediaLoader', vjs.MediaLoader);
|
||||
goog.exportSymbol('videojs.TextTrackDisplay', vjs.TextTrackDisplay);
|
||||
|
45
test/minified-api.html
Normal file
45
test/minified-api.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video.js Test Suite</title>
|
||||
|
||||
<!-- QUnit -->
|
||||
<link rel="stylesheet" href="../test/qunit/qunit/qunit.css" />
|
||||
<script src="../test/qunit/qunit/qunit.js"></script>
|
||||
|
||||
<!-- Video.js CSS -->
|
||||
<link rel="stylesheet" href="../src/css/video-js.css" type="text/css">
|
||||
|
||||
<!-- LIB COMPILED WITH NOT COMPILED TESTS
|
||||
Check publicly available APIs against compiled lib
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
|
||||
// ADD NEW TEST FILES HERE
|
||||
var tests = [
|
||||
'test/unit/api.js'
|
||||
];
|
||||
var projectRoot = '../';
|
||||
var scripts = [];
|
||||
|
||||
scripts = scripts.concat(['build/files/minified.video.js'], tests);
|
||||
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
document.write( "<script src='" + projectRoot + scripts[i] + "'><\/script>" );
|
||||
}
|
||||
|
||||
})()
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1 id="qunit-header">Video.js Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
39
test/unit/api.js
Normal file
39
test/unit/api.js
Normal file
@ -0,0 +1,39 @@
|
||||
module('Player Minified');
|
||||
|
||||
var PlayerTest = {
|
||||
makeTag: function(){
|
||||
var videoTag = document.createElement('video');
|
||||
videoTag.id = 'example_1';
|
||||
videoTag.className = 'video-js vjs-default-skin';
|
||||
return videoTag;
|
||||
}
|
||||
};
|
||||
|
||||
test('should export ready api call to public', function() {
|
||||
var videoTag = PlayerTest.makeTag();
|
||||
|
||||
var fixture = document.getElementById('qunit-fixture');
|
||||
fixture.appendChild(videoTag);
|
||||
|
||||
var player = _V_('example_1');
|
||||
ok(player.ready !== undefined, 'ready callback is defined');
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('should be able to initialize player twice on the same tag using string reference', function() {
|
||||
var videoTag = PlayerTest.makeTag();
|
||||
var id = videoTag.id;
|
||||
|
||||
var fixture = document.getElementById('qunit-fixture');
|
||||
fixture.appendChild(videoTag);
|
||||
|
||||
var player = _V_('example_1');
|
||||
player.dispose();
|
||||
ok(!document.getElementById(id), 'element is removed');
|
||||
|
||||
videoTag = PlayerTest.makeTag();
|
||||
fixture.appendChild(videoTag);
|
||||
|
||||
player = _V_('example_1');
|
||||
player.dispose();
|
||||
});
|
@ -235,3 +235,24 @@ test('should not play if firstplay event prevents default', function(){
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('should be able to initialize player twice on the same tag using string reference', function() {
|
||||
var videoTag = PlayerTest.makeTag();
|
||||
var id = videoTag.id;
|
||||
|
||||
var fixture = document.getElementById('qunit-fixture');
|
||||
fixture.appendChild(videoTag);
|
||||
|
||||
var player = vjs(videoTag.id);
|
||||
ok(player, 'player is created');
|
||||
player.dispose();
|
||||
|
||||
ok(!document.getElementById(id), 'element is removed');
|
||||
videoTag = PlayerTest.makeTag();
|
||||
fixture.appendChild(videoTag);
|
||||
|
||||
//here we receive cached version instead of real
|
||||
player = vjs(videoTag.id);
|
||||
//here it triggers error, because player was destroyed already after first dispose
|
||||
player.dispose();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user