mirror of https://github.com/embarklabs/embark.git
test(@embark/commmunication): add test for artifact generation
This also makes `fakeEmbark` configurable
This commit is contained in:
parent
67207a239a
commit
7ea9aa417d
|
@ -10,6 +10,15 @@ describe('stack/communication', () => {
|
|||
const { embark } = fakeEmbark();
|
||||
|
||||
beforeEach(() => {
|
||||
embark.setConfig({
|
||||
communicationConfig: {
|
||||
connection: {
|
||||
host: 'localhost',
|
||||
}
|
||||
},
|
||||
embarkConfig: {}
|
||||
});
|
||||
|
||||
communication = new Communication(embark);
|
||||
|
||||
communicationNodeLaunchFn = sinon.spy(done => {
|
||||
|
@ -48,4 +57,13 @@ describe('stack/communication', () => {
|
|||
assert(communicationNodeLaunchFn.calledOnce);
|
||||
assert(doneCb.calledOnce);
|
||||
});
|
||||
|
||||
test('it should register artifact file from configuration', () => {
|
||||
const pipelineRegisterHandler = sinon.spy((params, fn) => fn());
|
||||
embark.events.setCommandHandler('pipeline:register', pipelineRegisterHandler);
|
||||
embark.plugins.emitAndRunActionsForEvent('pipeline:generateAll:before', {}, doneCb);
|
||||
|
||||
assert(pipelineRegisterHandler.calledOnce);
|
||||
assert(doneCb.calledOnce);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const sinon = require('sinon');
|
||||
|
||||
class Embark {
|
||||
constructor(events, plugins) {
|
||||
constructor(events, plugins, config) {
|
||||
this.events = events;
|
||||
this.plugins = plugins;
|
||||
this.config = {
|
||||
blockchainConfig: {}
|
||||
};
|
||||
|
||||
this.config = config || {};
|
||||
this.assert = new EmbarkAssert(this);
|
||||
|
||||
this.logger = {
|
||||
|
@ -23,8 +20,13 @@ class Embark {
|
|||
}
|
||||
|
||||
teardown() {
|
||||
this.config = {};
|
||||
this.plugins.teardown();
|
||||
}
|
||||
|
||||
setConfig(config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
class EmbarkAssert {
|
||||
|
|
|
@ -2,11 +2,11 @@ const Embark = require('./embark');
|
|||
const Events = require('./events');
|
||||
const Plugins = require('./plugin');
|
||||
|
||||
const fakeEmbark = () => {
|
||||
const fakeEmbark = (config) => {
|
||||
const events = new Events();
|
||||
const plugins = new Plugins();
|
||||
|
||||
const embark = new Embark(events, plugins);
|
||||
const embark = new Embark(events, plugins, config);
|
||||
return {
|
||||
embark,
|
||||
plugins
|
||||
|
|
Loading…
Reference in New Issue