From acf4153963640c51e21187bb6d3eb3d6e38289c7 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 7 Nov 2017 20:48:24 +0000 Subject: [PATCH] feat: add a version method to all advanced plugin instances (#4714) --- src/js/plugin.js | 7 +++++++ test/unit/plugin-advanced.test.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/js/plugin.js b/src/js/plugin.js index 90285237dc..d743fa7cfb 100644 --- a/src/js/plugin.js +++ b/src/js/plugin.js @@ -219,6 +219,13 @@ class Plugin { player.on('dispose', this.dispose); } + /** + * Get the version of the plugin that was set on .VERSION + */ + version() { + return this.constructor.VERSION; + } + /** * Each event triggered by plugins includes a hash of additional data with * conventional properties. diff --git a/test/unit/plugin-advanced.test.js b/test/unit/plugin-advanced.test.js index 2ea499dbb4..64b5f56056 100644 --- a/test/unit/plugin-advanced.test.js +++ b/test/unit/plugin-advanced.test.js @@ -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),