1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-13 01:30:17 +02:00

fix: copy basic plugin properties onto the wrapper (#4100)

Copy basic plugin properties to prevent breaking older basic plugins.
This commit is contained in:
Brandon Casey
2017-02-21 15:49:42 -05:00
committed by Gary Katsevman
parent 405b29b8f1
commit 127cd7827e
2 changed files with 41 additions and 9 deletions

View File

@ -38,6 +38,13 @@ QUnit.test('setup', function(assert) {
assert.deepEqual(this.basic.firstCall.args, [{foo: 'bar'}, 123], 'the plugin had the correct arguments');
assert.ok(this.player.usingPlugin('basic'), 'the player now recognizes that the plugin was set up');
assert.ok(this.player.hasPlugin('basic'), 'player has the plugin available');
this.player.basic({foo: 'bar'}, 123);
assert.strictEqual(this.basic.callCount, 2, 'the plugin was called twice');
assert.strictEqual(this.basic.firstCall.thisValue, this.player, 'the plugin `this` value was the player');
assert.deepEqual(this.basic.firstCall.args, [{foo: 'bar'}, 123], 'the plugin had the correct arguments');
assert.ok(this.player.usingPlugin('basic'), 'the player now recognizes that the plugin was set up');
assert.ok(this.player.hasPlugin('basic'), 'player has the plugin available');
});
QUnit.test('"pluginsetup" event', function(assert) {
@ -58,3 +65,20 @@ QUnit.test('"pluginsetup" event', function(assert) {
plugin: this.basic
}, 'the event hash object is correct');
});
QUnit.test('properties are copied', function(assert) {
const foo = () => {};
foo.someProp = () => {};
foo.VERSION = '9.9.9';
Plugin.registerPlugin('foo', foo);
assert.strictEqual(this.player.foo.VERSION, foo.VERSION, 'properties are copied');
assert.strictEqual(this.player.foo.someProp, foo.someProp, 'properties are copied');
this.player.foo();
assert.strictEqual(this.player.foo.VERSION, foo.VERSION, 'properties still exist after init');
assert.strictEqual(this.player.foo.someProp, foo.someProp, 'properties still exist after init');
});