mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Initial plugin runtime api implementation
This commit is contained in:
68
test/unit/@node-red/runtime/lib/api/plugins_spec.js
Normal file
68
test/unit/@node-red/runtime/lib/api/plugins_spec.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const should = require("should");
|
||||
const sinon = require("sinon");
|
||||
|
||||
const NR_TEST_UTILS = require("nr-test-utils");
|
||||
const plugins = NR_TEST_UTILS.require("@node-red/runtime/lib/api/plugins")
|
||||
|
||||
const mockLog = () => ({
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
audit: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
})
|
||||
|
||||
describe("runtime-api/plugins", function() {
|
||||
const pluginList = [{id:"one",module:'test-module'},{id:"two",module:"node-red"}];
|
||||
const pluginConfigs = "123";
|
||||
|
||||
describe("getPluginList", function() {
|
||||
it("gets the plugin list", function() {
|
||||
plugins.init({
|
||||
log: mockLog(),
|
||||
plugins: {
|
||||
getPluginList: function() { return pluginList}
|
||||
}
|
||||
});
|
||||
return plugins.getPluginList({}).then(function(result) {
|
||||
result.should.eql(pluginList);
|
||||
})
|
||||
});
|
||||
});
|
||||
describe("getPluginConfigs", function() {
|
||||
it("gets the plugin configs", function() {
|
||||
plugins.init({
|
||||
log: mockLog(),
|
||||
plugins: {
|
||||
getPluginConfigs: function() { return pluginConfigs}
|
||||
}
|
||||
});
|
||||
return plugins.getPluginConfigs({}).then(function(result) {
|
||||
result.should.eql(pluginConfigs);
|
||||
})
|
||||
});
|
||||
});
|
||||
describe("getPluginCatalogs", function() {
|
||||
it("gets the plugin catalogs", function() {
|
||||
plugins.init({
|
||||
log: mockLog(),
|
||||
plugins: {
|
||||
getPluginList: function() { return pluginList}
|
||||
},
|
||||
i18n: {
|
||||
i: {
|
||||
changeLanguage: function(lang,done) { done && done() },
|
||||
getResourceBundle: function(lang, id) { return {lang,id}}
|
||||
}
|
||||
}
|
||||
});
|
||||
return plugins.getPluginCatalogs({lang: "en-US"}).then(function(result) {
|
||||
JSON.stringify(result).should.eql(JSON.stringify({ one: { lang: "en-US", id: "one" } }))
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
});
|
13
test/unit/@node-red/runtime/lib/plugins_spec.js
Normal file
13
test/unit/@node-red/runtime/lib/plugins_spec.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const should = require("should");
|
||||
const sinon = require("sinon");
|
||||
const NR_TEST_UTILS = require("nr-test-utils");
|
||||
|
||||
const plugins = NR_TEST_UTILS.require("@node-red/runtime/lib/plugins");
|
||||
|
||||
describe("runtime/plugins",function() {
|
||||
|
||||
it.skip("delegates all functions to registry module", function() {
|
||||
// There's no easy way to test this as we can't stub the registry functions
|
||||
// before the plugin module gets a reference to them
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user