1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

fix websocket feedback test - now doesn't spin

This commit is contained in:
Dave Conway-Jones 2018-09-26 16:03:22 +01:00
parent 1a7868159a
commit c9dc9b4fe9
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 10 additions and 7 deletions

View File

@ -250,10 +250,11 @@ module.exports = function(RED) {
this.on("input", function(msg) { this.on("input", function(msg) {
var payload; var payload;
if (this.serverConfig.wholemsg) { if (this.serverConfig.wholemsg) {
var sess = JSON.stringify(msg._session); var sess;
if (msg._session) { sess = JSON.stringify(msg._session); }
delete msg._session; delete msg._session;
payload = JSON.stringify(msg); payload = JSON.stringify(msg);
msg._session = JSON.parse(sess); if (sess) { msg._session = JSON.parse(sess); }
} }
else if (msg.hasOwnProperty("payload")) { else if (msg.hasOwnProperty("payload")) {
if (!Buffer.isBuffer(msg.payload)) { // if it's not a buffer make sure it's a string. if (!Buffer.isBuffer(msg.payload)) { // if it's not a buffer make sure it's a string.

View File

@ -481,7 +481,7 @@ describe('websocket Node', function() {
}); });
}); });
it('should feedback', function(done) { it('should NOT feedback more than once', function(done) {
var flow = [ var flow = [
{ id: "server", type: "websocket-listener", path: "/ws", wholemsg: "true" }, { id: "server", type: "websocket-listener", path: "/ws", wholemsg: "true" },
{ id: "client", type: "websocket-client", path: getWsUrl("/ws"), wholemsg: "true" }, { id: "client", type: "websocket-client", path: getWsUrl("/ws"), wholemsg: "true" },
@ -497,11 +497,13 @@ describe('websocket Node', function() {
}); });
var acc = 0; var acc = 0;
helper.getNode("output").on("input", function(msg) { helper.getNode("output").on("input", function(msg) {
if (acc++ > 20) { acc = acc + 1;
helper.clearFlows();
done();
}
}); });
setTimeout( function() {
acc.should.equal(1);
helper.clearFlows();
done();
}, 250);
}); });
}); });
}); });