Permalink
Browse files

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

  • Loading branch information...
BrandonOCasey authored and gkatsev committed Nov 7, 2017
1 parent c213737 commit acf4153963640c51e21187bb6d3eb3d6e38289c7
Showing with 11 additions and 0 deletions.
  1. +7 −0 src/js/plugin.js
  2. +4 −0 test/unit/plugin-advanced.test.js
View
@@ -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.
@@ -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),

0 comments on commit acf4153

Please sign in to comment.