diff --git a/src/core/plugins/index.js b/src/core/plugins/index.js index a8b22c91..0c4e439b 100644 --- a/src/core/plugins/index.js +++ b/src/core/plugins/index.js @@ -78,9 +78,17 @@ class PluginIndex { }); } + /** + * resolves remote values + * @returns {Promise} + */ remote_value(option) { return Promise.resolve(this.parsePluginId(option.remote_values)) - .then(([p, f]) => this.plugins[p][`remote_values__${f}`](option)) + .then(([p, f]) => + this.plugins[p] && this.plugins[p][`remote_values__${f}`] + ? this.plugins[p][`remote_values__${f}`](option) + : [] + ) .then(values => (option.values = values)); } diff --git a/src/core/plugins/index.spec.js b/src/core/plugins/index.spec.js index 3c7aec37..daf16f12 100644 --- a/src/core/plugins/index.spec.js +++ b/src/core/plugins/index.spec.js @@ -67,6 +67,20 @@ describe("PluginIndex", () => { pluginIndex.plugins.systemimage.remote_values__channels.mockRestore(); }); }); + it("should resolve empty on invalid plugin", () => { + return pluginIndex + .remote_value({ remote_values: { "systemimage:invalid": { a: "b" } } }) + .then(r => { + expect(r).toEqual([]); + }); + }); + it("should resolve empty on invalid provider", () => { + return pluginIndex + .remote_value({ remote_values: { "invalid:invalid": { a: "b" } } }) + .then(r => { + expect(r).toEqual([]); + }); + }); }); describe("getPluginArray()", () => { it("should return plugin array", () =>