Skip to content

Commit

Permalink
feat: add a version method to all advanced plugin instances (#4714)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored and gkatsev committed Nov 7, 2017
1 parent c213737 commit acf4153
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/js/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions test/unit/plugin-advanced.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ QUnit.module('Plugin: advanced', {
}
}

MockPlugin.VERSION = '1.0.0';

this.MockPlugin = MockPlugin;
Plugin.registerPlugin('mock', MockPlugin);
},
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit acf4153

Please sign in to comment.