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();
|
const { embark } = fakeEmbark();
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
embark.setConfig({
|
||||||
|
communicationConfig: {
|
||||||
|
connection: {
|
||||||
|
host: 'localhost',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
embarkConfig: {}
|
||||||
|
});
|
||||||
|
|
||||||
communication = new Communication(embark);
|
communication = new Communication(embark);
|
||||||
|
|
||||||
communicationNodeLaunchFn = sinon.spy(done => {
|
communicationNodeLaunchFn = sinon.spy(done => {
|
||||||
|
@ -48,4 +57,13 @@ describe('stack/communication', () => {
|
||||||
assert(communicationNodeLaunchFn.calledOnce);
|
assert(communicationNodeLaunchFn.calledOnce);
|
||||||
assert(doneCb.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');
|
const sinon = require('sinon');
|
||||||
|
|
||||||
class Embark {
|
class Embark {
|
||||||
constructor(events, plugins) {
|
constructor(events, plugins, config) {
|
||||||
this.events = events;
|
this.events = events;
|
||||||
this.plugins = plugins;
|
this.plugins = plugins;
|
||||||
this.config = {
|
this.config = config || {};
|
||||||
blockchainConfig: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.assert = new EmbarkAssert(this);
|
this.assert = new EmbarkAssert(this);
|
||||||
|
|
||||||
this.logger = {
|
this.logger = {
|
||||||
|
@ -23,8 +20,13 @@ class Embark {
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
|
this.config = {};
|
||||||
this.plugins.teardown();
|
this.plugins.teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setConfig(config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EmbarkAssert {
|
class EmbarkAssert {
|
||||||
|
|
|
@ -2,11 +2,11 @@ const Embark = require('./embark');
|
||||||
const Events = require('./events');
|
const Events = require('./events');
|
||||||
const Plugins = require('./plugin');
|
const Plugins = require('./plugin');
|
||||||
|
|
||||||
const fakeEmbark = () => {
|
const fakeEmbark = (config) => {
|
||||||
const events = new Events();
|
const events = new Events();
|
||||||
const plugins = new Plugins();
|
const plugins = new Plugins();
|
||||||
|
|
||||||
const embark = new Embark(events, plugins);
|
const embark = new Embark(events, plugins, config);
|
||||||
return {
|
return {
|
||||||
embark,
|
embark,
|
||||||
plugins
|
plugins
|
||||||
|
|
Loading…
Reference in New Issue