mirror of https://github.com/embarklabs/embark.git
feat(@embark/testing): add missing APIs to register console commands and API calls
This commit also introduces an IPC mock object, needed for Embark to work as a dependency within the console module
This commit is contained in:
parent
e8b5c7ab89
commit
bef582d312
|
@ -51,6 +51,7 @@
|
|||
"async": "2.6.1",
|
||||
"core-js": "3.4.3",
|
||||
"refute": "1.0.2",
|
||||
"fs-extra": "8.1.0",
|
||||
"sinon": "7.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const sinon = require('sinon');
|
||||
import fs from 'fs-extra';
|
||||
|
||||
class Embark {
|
||||
constructor(events, plugins, config) {
|
||||
|
@ -6,6 +7,7 @@ class Embark {
|
|||
this.plugins = plugins;
|
||||
this.config = config || {};
|
||||
this.assert = new EmbarkAssert(this);
|
||||
this.fs = fs;
|
||||
|
||||
this.logger = {
|
||||
debug: sinon.fake(),
|
||||
|
@ -19,6 +21,10 @@ class Embark {
|
|||
this.plugins.registerActionForEvent(name, cb);
|
||||
}
|
||||
|
||||
registerConsoleCommand(options) {
|
||||
this.plugins.registerConsoleCommand(options);
|
||||
}
|
||||
|
||||
teardown() {
|
||||
this.config = {};
|
||||
this.plugins.teardown();
|
||||
|
|
|
@ -7,6 +7,16 @@ const fakeEmbark = (config) => {
|
|||
const events = new Events();
|
||||
const plugins = new Plugins();
|
||||
|
||||
const ipc = {
|
||||
isServer: () => { return true; },
|
||||
broadcast: () => {},
|
||||
on: () => {},
|
||||
isClient: () => { return false; }
|
||||
};
|
||||
|
||||
config = config || {};
|
||||
config.ipc = config.ipc || ipc;
|
||||
|
||||
const embark = new Embark(events, plugins, config);
|
||||
return {
|
||||
embark,
|
||||
|
|
|
@ -27,6 +27,10 @@ class Plugins {
|
|||
this.plugin.registerActionForEvent(name, cb);
|
||||
}
|
||||
|
||||
registerConsoleCommand(options) {
|
||||
this.plugin.registerConsoleCommand(options);
|
||||
}
|
||||
|
||||
teardown() {
|
||||
this.plugin.listeners = {};
|
||||
this.plugins.forEach(plugin => plugin.teardown());
|
||||
|
@ -49,6 +53,7 @@ class Plugin {
|
|||
constructor() {
|
||||
this.listeners = {};
|
||||
this.pluginTypes = [];
|
||||
this.console = [];
|
||||
this.compilers = [];
|
||||
}
|
||||
|
||||
|
@ -77,6 +82,15 @@ class Plugin {
|
|||
this.addPluginType('compilers');
|
||||
}
|
||||
|
||||
registerAPICall(_method, _endpoint, _callback) {
|
||||
|
||||
}
|
||||
|
||||
registerConsoleCommand(options) {
|
||||
this.console.push(options);
|
||||
this.addPluginType('console');
|
||||
}
|
||||
|
||||
teardown() {
|
||||
this.compilers = [];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue