Comparing version 0.3.2 to 0.3.3
@@ -523,2 +523,10 @@ require("source-map-support").install(); | ||
_createClass(Response, [{ | ||
key: "init", | ||
value: function init() { | ||
this.component.channelManager.channels.forEach(function (channel) { | ||
channel.status = STATUS.INIT; | ||
channel.output = null; | ||
}); | ||
} | ||
}, { | ||
key: "prepare", | ||
@@ -567,2 +575,3 @@ value: function prepare(output, channelName) { | ||
value: function send(output, channelName) { | ||
this.init(); | ||
this.prepare(output, channelName); | ||
@@ -569,0 +578,0 @@ this.done(); |
{ | ||
"name": "horpyna", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "promised modules flow control core library", | ||
@@ -56,3 +56,6 @@ "main": "index.js", | ||
"webpack": "^1.13.1" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.4.0" | ||
} | ||
} |
@@ -75,3 +75,3 @@ import Root from "./root"; | ||
* @param component parent component | ||
* @param channel parent channel name | ||
* @param channelName parent channel name | ||
*/ | ||
@@ -78,0 +78,0 @@ bind(component, channelName) { |
@@ -9,2 +9,9 @@ import * as STATUS from "../constants/statuses"; | ||
init() { | ||
this.component.channelManager.channels.forEach(channel => { | ||
channel.status = STATUS.INIT; | ||
channel.output = null; | ||
}); | ||
} | ||
prepare(output, channelName) { | ||
@@ -44,2 +51,3 @@ if(this.component.rootComponent.status === STATUS.PROCESS) { | ||
send(output, channelName) { | ||
this.init(); | ||
this.prepare(output, channelName); | ||
@@ -46,0 +54,0 @@ this.done(); |
@@ -209,3 +209,3 @@ import sinon from "sinon"; | ||
describe("Check channels", () => { | ||
it("should return message to final component connected by custom channel", (done) => { | ||
it("should return message to final component connected by custom channel", done => { | ||
let spyA = sinon.spy(); | ||
@@ -240,3 +240,48 @@ let spyB = sinon.spy(); | ||
describe("Custom structures", () => { | ||
const CHANNEL_AA = "channelAA"; | ||
const CHANNEL_AB = "channelAB"; | ||
it("should finish", done => { | ||
let spyAA = sinon.spy(); | ||
let spyAB = sinon.spy(); | ||
let spyB = sinon.spy(); | ||
let spyC = sinon.spy(); | ||
let componentA = new Horpyna.Component((request, response) => { | ||
if(request.input) { | ||
spyAB(); | ||
response.send(null, CHANNEL_AB); | ||
} else { | ||
spyAA(); | ||
response.send(null, CHANNEL_AA); | ||
} | ||
}); | ||
componentA.createChannel(CHANNEL_AA); | ||
componentA.createChannel(CHANNEL_AB); | ||
let componentB = new Horpyna.Component((request, response) => { | ||
spyB(); | ||
response.send(true); | ||
}); | ||
componentB.bind(componentA, CHANNEL_AA); | ||
componentA.bind(componentB); | ||
let componentC = new Horpyna.Component((request, response) => { | ||
spyC(); | ||
response.send(); | ||
}); | ||
componentC.bind(componentA, CHANNEL_AB); | ||
componentC.final(); | ||
let promise = componentA.run(); | ||
promise.then((response) => { | ||
expect(spyAA.calledOnce).to.be.true; | ||
expect(spyAB.calledOnce).to.be.true; | ||
expect(spyB.calledOnce).to.be.true; | ||
expect(spyC.calledOnce).to.be.true; | ||
expect(spyAA.calledBefore(spyAB)).to.be.true; | ||
expect(spyAA.calledBefore(spyB)).to.be.true; | ||
expect(spyB.calledBefore(spyAB)).to.be.true; | ||
expect(spyAB.calledBefore(spyC)).to.be.true; | ||
done(); | ||
}); | ||
}) | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
84625
1143
1
+ Addedbluebird@^3.4.0
+ Addedbluebird@3.7.2(transitive)