mirror of
https://github.com/videojs/video.js.git
synced 2025-02-16 12:23:54 +02:00
Added test for the plugin interface.
This commit is contained in:
parent
8671f1ff91
commit
6f2597cc8d
@ -25,6 +25,7 @@
|
||||
'test/unit/player.js',
|
||||
'test/unit/core.js',
|
||||
'test/unit/media.html5.js'
|
||||
'test/unit/plugins.js'
|
||||
];
|
||||
var compiledTests = "build/files/test.minified.video.js";
|
||||
var scripts = [];
|
||||
|
63
test/unit/plugins.js
Normal file
63
test/unit/plugins.js
Normal file
@ -0,0 +1,63 @@
|
||||
module("Plugins");
|
||||
|
||||
test('Plugin should get initialized and receive options', function(){
|
||||
expect(2);
|
||||
|
||||
vjs.plugin('myPlugin1', function(options){
|
||||
ok(true, 'Plugin initialized');
|
||||
ok(options['test'], 'Option passed through');
|
||||
});
|
||||
|
||||
vjs.plugin('myPlugin2', function(options){
|
||||
ok(false, 'Plugin initialized and should not have been')
|
||||
});
|
||||
|
||||
var player = PlayerTest.makePlayer({
|
||||
'plugins': {
|
||||
'myPlugin1': {
|
||||
'test': true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('Plugin should have the option of being initilized outside of player init', function(){
|
||||
expect(3)
|
||||
|
||||
vjs.plugin('myPlugin3', function(options){
|
||||
ok(true, 'Plugin initialized after player init');
|
||||
ok(options['test'], 'Option passed through');
|
||||
});
|
||||
|
||||
var player = PlayerTest.makePlayer({});
|
||||
|
||||
ok(player.myPlugin3, 'Plugin has direct access on player instance');
|
||||
|
||||
player.myPlugin3({
|
||||
'test': true
|
||||
});
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('Plugin should be able to add a UI component', function(){
|
||||
expect(2)
|
||||
|
||||
vjs.plugin('myPlugin4', function(options){
|
||||
ok(instanceof this === 'vjs.Player', 'Plugin executed in player scope by default');
|
||||
this.addChild('component');
|
||||
});
|
||||
|
||||
var player = PlayerTest.makePlayer({});
|
||||
player.myPlugin4({
|
||||
'test': true
|
||||
});
|
||||
|
||||
var comp = player.getChild('component');
|
||||
ok(comp, 'Plugin added a component to the player'
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user