1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

feat: add a version method to all advanced plugin instances (#4714)

This commit is contained in:
Brandon Casey 2017-11-07 20:48:24 +00:00 committed by Gary Katsevman
parent c213737f7a
commit acf4153963
2 changed files with 11 additions and 0 deletions

View File

@ -219,6 +219,13 @@ class Plugin {
player.on('dispose', this.dispose);
}
/**
* Get the version of the plugin that was set on <pluginName>.VERSION
*/
version() {
return this.constructor.VERSION;
}
/**
* Each event triggered by plugins includes a hash of additional data with
* conventional properties.

View File

@ -17,6 +17,8 @@ QUnit.module('Plugin: advanced', {
}
}
MockPlugin.VERSION = '1.0.0';
this.MockPlugin = MockPlugin;
Plugin.registerPlugin('mock', MockPlugin);
},
@ -59,6 +61,8 @@ QUnit.test('setup', function(assert) {
assert.strictEqual(typeof instance.one, 'function', 'instance is evented');
assert.strictEqual(typeof instance.trigger, 'function', 'instance is evented');
assert.strictEqual(typeof instance.dispose, 'function', 'instance has dispose method');
assert.strictEqual(typeof instance.version, 'function', 'instance has version method');
assert.strictEqual(instance.version(), '1.0.0', 'version function returns VERSION value');
assert.throws(
() => new Plugin(this.player),