node-red-contrib-antenna-genius 0.2.6-beta → 0.2.7-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Utils.js +72 -55
- package/antenna-genius-activate-antenna.html +14 -13
- package/antenna-genius-activate-antenna.js +34 -16
- package/antenna-genius-antenna-status.html +29 -18
- package/antenna-genius-antenna-status.js +63 -26
- package/antenna-genius-band-labels.html +14 -12
- package/antenna-genius-band-labels.js +38 -15
- package/antenna-genius-server.html +35 -21
- package/antenna-genius-server.js +34 -24
- package/package.json +1 -1
- package/test/Utils.spec.js +141 -0
- package/test/antenna-genius-activate-antenna.spec.js +110 -72
- package/test/antenna-genius-antenna-status.spec.js +163 -106
- package/test/antenna-genius-band-labels.spec.js +137 -103
- package/test/antenna-genius-server.spec.js +51 -31
|
@@ -9,35 +9,41 @@ module.exports = (RED) => {
|
|
|
9
9
|
this.server = RED.nodes.getNode(config.server);
|
|
10
10
|
|
|
11
11
|
this.server.updatesEventEmitter.on("connected", () => {
|
|
12
|
-
if(this.server.info.name) {
|
|
13
|
-
this.status({
|
|
12
|
+
if (this.server.info.name) {
|
|
13
|
+
this.status({
|
|
14
|
+
fill: "green",
|
|
15
|
+
shape: "dot",
|
|
16
|
+
text: this.server.info.name,
|
|
17
|
+
});
|
|
14
18
|
}
|
|
15
19
|
});
|
|
16
20
|
|
|
17
|
-
this.server.updatesEventEmitter.on(
|
|
18
|
-
this.status({
|
|
21
|
+
this.server.updatesEventEmitter.on("closed", () => {
|
|
22
|
+
this.status({
|
|
23
|
+
fill: "red",
|
|
24
|
+
shape: "ring",
|
|
25
|
+
text: "disconnected",
|
|
26
|
+
});
|
|
19
27
|
});
|
|
20
28
|
|
|
21
29
|
this.server.updatesEventEmitter.on("status", (forceUpdate) => {
|
|
22
30
|
let bandIndexA = this.server.status.portA_band;
|
|
23
31
|
let bandIndexB = this.server.status.portB_band;
|
|
24
32
|
|
|
25
|
-
if(bandIndexA === undefined || bandIndexB === undefined) {
|
|
33
|
+
if (bandIndexA === undefined || bandIndexB === undefined) {
|
|
26
34
|
return;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
if(bandIndexA < 0 || bandIndexA >= this.server.bands.length)
|
|
30
|
-
{
|
|
37
|
+
if (bandIndexA < 0 || bandIndexA >= this.server.bands.length) {
|
|
31
38
|
return;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
if(bandIndexB < 0 || bandIndexB >= this.server.bands.length)
|
|
35
|
-
{
|
|
41
|
+
if (bandIndexB < 0 || bandIndexB >= this.server.bands.length) {
|
|
36
42
|
return;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
let bandNameA = this.server.bands[bandIndexA].
|
|
40
|
-
let bandNameB = this.server.bands[bandIndexB].
|
|
45
|
+
let bandNameA = this.server.bands[bandIndexA].name;
|
|
46
|
+
let bandNameB = this.server.bands[bandIndexB].name;
|
|
41
47
|
|
|
42
48
|
let changed = forceUpdate;
|
|
43
49
|
if (bandNameA !== this.bandNameA) {
|
|
@@ -49,13 +55,30 @@ module.exports = (RED) => {
|
|
|
49
55
|
this.bandNameB = bandNameB;
|
|
50
56
|
}
|
|
51
57
|
if (changed) {
|
|
52
|
-
node.send({
|
|
53
|
-
|
|
58
|
+
node.send({
|
|
59
|
+
payload: {
|
|
60
|
+
bandLabelA: bandNameA,
|
|
61
|
+
bandLabelB: bandNameB,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
this.status({
|
|
65
|
+
fill: "green",
|
|
66
|
+
shape: "dot",
|
|
67
|
+
text:
|
|
68
|
+
this.server.info.name +
|
|
69
|
+
" - " +
|
|
70
|
+
bandNameA +
|
|
71
|
+
"/" +
|
|
72
|
+
bandNameB,
|
|
73
|
+
});
|
|
54
74
|
}
|
|
55
75
|
});
|
|
56
76
|
|
|
57
77
|
this.server.connect();
|
|
58
78
|
}
|
|
59
79
|
}
|
|
60
|
-
RED.nodes.registerType(
|
|
61
|
-
|
|
80
|
+
RED.nodes.registerType(
|
|
81
|
+
"antenna-genius-band-labels",
|
|
82
|
+
AntennaGeniusBandLabels
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -1,41 +1,55 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType(
|
|
3
|
-
category:
|
|
4
|
-
color:
|
|
2
|
+
RED.nodes.registerType("antenna-genius-server", {
|
|
3
|
+
category: "config",
|
|
4
|
+
color: "#FFF0F0",
|
|
5
5
|
defaults: {
|
|
6
|
-
host: {value:"localhost",required:true},
|
|
7
|
-
port: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
host: { value: "localhost", required: true },
|
|
7
|
+
port: {
|
|
8
|
+
value: 9007,
|
|
9
|
+
required: true,
|
|
10
|
+
validate: RED.validators.number(),
|
|
11
|
+
},
|
|
12
|
+
disabledColor: { value: "Black", required: true },
|
|
13
|
+
activeColor: { value: "Green", required: true },
|
|
14
|
+
selectedColor: { value: "Blue", required: true },
|
|
15
|
+
autoConnect: { value: true },
|
|
12
16
|
},
|
|
13
|
-
label: function() {
|
|
17
|
+
label: function () {
|
|
14
18
|
return "antenna genius at " + this.host + ":" + this.port;
|
|
15
|
-
}
|
|
19
|
+
},
|
|
16
20
|
});
|
|
17
21
|
</script>
|
|
18
22
|
|
|
19
23
|
<script type="text/html" data-template-name="antenna-genius-server">
|
|
20
24
|
<div class="form-row">
|
|
21
|
-
<label for="node-config-input-host"
|
|
22
|
-
|
|
25
|
+
<label for="node-config-input-host"
|
|
26
|
+
><i class="fa fa-bookmark"></i> Host</label
|
|
27
|
+
>
|
|
28
|
+
<input type="text" id="node-config-input-host" />
|
|
23
29
|
</div>
|
|
24
30
|
<div class="form-row">
|
|
25
|
-
<label for="node-config-input-port"
|
|
26
|
-
|
|
31
|
+
<label for="node-config-input-port"
|
|
32
|
+
><i class="fa fa-bookmark"></i> Port</label
|
|
33
|
+
>
|
|
34
|
+
<input type="text" id="node-config-input-port" />
|
|
27
35
|
</div>
|
|
28
36
|
<div class="form-row">
|
|
29
|
-
<label for="node-config-input-disabledColor"
|
|
30
|
-
|
|
37
|
+
<label for="node-config-input-disabledColor"
|
|
38
|
+
><i class="fa fa-bookmark"></i> Disabled Background</label
|
|
39
|
+
>
|
|
40
|
+
<input type="text" id="node-config-input-disabledColor" />
|
|
31
41
|
</div>
|
|
32
42
|
<div class="form-row">
|
|
33
|
-
<label for="node-config-input-activeColor"
|
|
34
|
-
|
|
43
|
+
<label for="node-config-input-activeColor"
|
|
44
|
+
><i class="fa fa-bookmark"></i> Active Background</label
|
|
45
|
+
>
|
|
46
|
+
<input type="text" id="node-config-input-activeColor" />
|
|
35
47
|
</div>
|
|
36
48
|
<div class="form-row">
|
|
37
|
-
<label for="node-config-input-selectedColor"
|
|
38
|
-
|
|
49
|
+
<label for="node-config-input-selectedColor"
|
|
50
|
+
><i class="fa fa-bookmark"></i> Selected Background</label
|
|
51
|
+
>
|
|
52
|
+
<input type="text" id="node-config-input-selectedColor" />
|
|
39
53
|
</div>
|
|
40
54
|
</script>
|
|
41
55
|
|
package/antenna-genius-server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const Net = require(
|
|
2
|
-
const {PromiseSocket} = require("promise-socket");
|
|
3
|
-
const EventEmitter = require(
|
|
4
|
-
const Utils = require(
|
|
1
|
+
const Net = require("net");
|
|
2
|
+
const { PromiseSocket } = require("promise-socket");
|
|
3
|
+
const EventEmitter = require("events");
|
|
4
|
+
const Utils = require("./Utils");
|
|
5
5
|
|
|
6
6
|
class UpdatesEventEmitter extends EventEmitter {}
|
|
7
7
|
|
|
@@ -30,30 +30,34 @@ module.exports = (RED) => {
|
|
|
30
30
|
this.client = new Net.Socket();
|
|
31
31
|
this.connected = false;
|
|
32
32
|
|
|
33
|
-
this.client.on(
|
|
34
|
-
this.log(
|
|
33
|
+
this.client.on("close", () => {
|
|
34
|
+
this.log("TCP connection disconnected with the server.");
|
|
35
35
|
clearInterval(this.interval);
|
|
36
36
|
clearTimeout(this.timer);
|
|
37
37
|
|
|
38
|
-
if(this.updatesEventEmitter.listenerCount(
|
|
39
|
-
this.log(
|
|
38
|
+
if (this.updatesEventEmitter.listenerCount("closed") == 0) {
|
|
39
|
+
this.log(
|
|
40
|
+
"Stop retrying. No nodes are refering this connection anymore."
|
|
41
|
+
);
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
if(this.autoConnect) {
|
|
44
|
-
this.log(
|
|
45
|
+
if (this.autoConnect) {
|
|
46
|
+
this.log(
|
|
47
|
+
"TCP connection failed with the server. Will try to reconnect in 5 seconds"
|
|
48
|
+
);
|
|
45
49
|
this.timer = setTimeout(() => {
|
|
46
|
-
this.log(
|
|
50
|
+
this.log("Reconnecting...");
|
|
47
51
|
this.connect();
|
|
48
52
|
}, 5000);
|
|
49
53
|
this.updatesEventEmitter.emit("closed");
|
|
50
54
|
}
|
|
51
55
|
});
|
|
52
56
|
|
|
53
|
-
this.client.on(
|
|
54
|
-
this.log(
|
|
57
|
+
this.client.on("connect", async () => {
|
|
58
|
+
this.log("TCP connection established with the server.");
|
|
55
59
|
this.connected = true;
|
|
56
|
-
|
|
60
|
+
|
|
57
61
|
const promiseClient = new PromiseSocket(this.client);
|
|
58
62
|
|
|
59
63
|
let command = Utils.encode(0, 0, 401, 0, "");
|
|
@@ -85,12 +89,18 @@ module.exports = (RED) => {
|
|
|
85
89
|
}
|
|
86
90
|
this.updatesEventEmitter.emit("bands");
|
|
87
91
|
|
|
88
|
-
this.client.on(
|
|
92
|
+
this.client.on("data", (packet) => {
|
|
89
93
|
let decoded = Utils.decode(packet);
|
|
90
|
-
if(decoded.command == 401) {
|
|
91
|
-
this.status = {
|
|
94
|
+
if (decoded.command == 401) {
|
|
95
|
+
this.status = {
|
|
96
|
+
...this.status,
|
|
97
|
+
...Utils.decode(packet),
|
|
98
|
+
};
|
|
92
99
|
this.refresh = (this.refresh + 1) % 1500;
|
|
93
|
-
this.updatesEventEmitter.emit(
|
|
100
|
+
this.updatesEventEmitter.emit(
|
|
101
|
+
"status",
|
|
102
|
+
this.refresh == 0
|
|
103
|
+
);
|
|
94
104
|
}
|
|
95
105
|
});
|
|
96
106
|
|
|
@@ -102,13 +112,13 @@ module.exports = (RED) => {
|
|
|
102
112
|
|
|
103
113
|
this.forceUpdate();
|
|
104
114
|
this.updatesEventEmitter.emit("connected");
|
|
105
|
-
})
|
|
115
|
+
});
|
|
106
116
|
|
|
107
|
-
this.client.on(
|
|
117
|
+
this.client.on("error", (err) => {
|
|
108
118
|
this.warn(err);
|
|
109
119
|
});
|
|
110
120
|
|
|
111
|
-
this.on(
|
|
121
|
+
this.on("close", (done) => {
|
|
112
122
|
clearInterval(this.interval);
|
|
113
123
|
clearTimeout(this.timer);
|
|
114
124
|
this.autoConnect = false;
|
|
@@ -120,7 +130,7 @@ module.exports = (RED) => {
|
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
connect() {
|
|
123
|
-
if(this.autoConnect && !this.connected & !this.client.connecting) {
|
|
133
|
+
if (this.autoConnect && !this.connected & !this.client.connecting) {
|
|
124
134
|
this.client.connect(this.port, this.host);
|
|
125
135
|
}
|
|
126
136
|
}
|
|
@@ -130,5 +140,5 @@ module.exports = (RED) => {
|
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
|
|
133
|
-
RED.nodes.registerType("antenna-genius-server",AntennaGeniusServerNode);
|
|
134
|
-
}
|
|
143
|
+
RED.nodes.registerType("antenna-genius-server", AntennaGeniusServerNode);
|
|
144
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
const { encode, decode } = require("../Utils.js");
|
|
2
|
+
|
|
3
|
+
describe("Utils", () => {
|
|
4
|
+
it("should encode null input gracefully", (done) => {
|
|
5
|
+
let data = encode();
|
|
6
|
+
expect(data).toBeDefined();
|
|
7
|
+
expect(data).toBe("!0007!000000!");
|
|
8
|
+
done();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should encode input correctly", (done) => {
|
|
12
|
+
let data = encode(7, 3, 4095, 31, "1");
|
|
13
|
+
expect(data).toBeDefined();
|
|
14
|
+
expect(data).toBe("!0008!fffffc!1");
|
|
15
|
+
done();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should decode null input gracefully", (done) => {
|
|
19
|
+
let data = decode();
|
|
20
|
+
expect(data).toBeDefined();
|
|
21
|
+
expect(data).toStrictEqual({
|
|
22
|
+
command: 0,
|
|
23
|
+
error: 0,
|
|
24
|
+
length: "0007",
|
|
25
|
+
method: 0,
|
|
26
|
+
payload: "",
|
|
27
|
+
protocol: 0,
|
|
28
|
+
revision: 0,
|
|
29
|
+
});
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should decode 24 input correctly", (done) => {
|
|
34
|
+
let command = encode(0, 0, 24, 0, "") + "1;2;Name";
|
|
35
|
+
let data = decode(command);
|
|
36
|
+
expect(data).toBeDefined();
|
|
37
|
+
expect(data).toStrictEqual({
|
|
38
|
+
command: 24,
|
|
39
|
+
error: 0,
|
|
40
|
+
length: "0007",
|
|
41
|
+
method: 0,
|
|
42
|
+
payload: "1;2;Name",
|
|
43
|
+
protocol: 0,
|
|
44
|
+
revision: 0,
|
|
45
|
+
identification: 1,
|
|
46
|
+
group: 2,
|
|
47
|
+
name: "Name",
|
|
48
|
+
});
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should decode 82 input correctly", (done) => {
|
|
53
|
+
let command = encode(0, 0, 82, 0, "") + "1;Name;2;3";
|
|
54
|
+
let data = decode(command);
|
|
55
|
+
expect(data).toBeDefined();
|
|
56
|
+
expect(data).toStrictEqual({
|
|
57
|
+
command: 82,
|
|
58
|
+
cutoff_lower: 2,
|
|
59
|
+
cutoff_upper: 3,
|
|
60
|
+
error: 0,
|
|
61
|
+
index: 1,
|
|
62
|
+
length: "0007",
|
|
63
|
+
method: 0,
|
|
64
|
+
name: "Name",
|
|
65
|
+
payload: "1;Name;2;3",
|
|
66
|
+
protocol: 0,
|
|
67
|
+
revision: 0,
|
|
68
|
+
});
|
|
69
|
+
done();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should decode 82 input correctly", (done) => {
|
|
73
|
+
let command = encode(0, 0, 82, 0, "") + "1;Name;2;3";
|
|
74
|
+
let data = decode(command);
|
|
75
|
+
expect(data).toBeDefined();
|
|
76
|
+
expect(data).toStrictEqual({
|
|
77
|
+
command: 82,
|
|
78
|
+
cutoff_lower: 2,
|
|
79
|
+
cutoff_upper: 3,
|
|
80
|
+
error: 0,
|
|
81
|
+
index: 1,
|
|
82
|
+
length: "0007",
|
|
83
|
+
method: 0,
|
|
84
|
+
name: "Name",
|
|
85
|
+
payload: "1;Name;2;3",
|
|
86
|
+
protocol: 0,
|
|
87
|
+
revision: 0,
|
|
88
|
+
});
|
|
89
|
+
done();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should decode 401 input correctly", (done) => {
|
|
93
|
+
let command =
|
|
94
|
+
encode(0, 0, 401, 0, "") + "1;2;3;4;5;6;7;8;9;10;11;12;13";
|
|
95
|
+
let data = decode(command);
|
|
96
|
+
expect(data).toBeDefined();
|
|
97
|
+
expect(data).toStrictEqual({
|
|
98
|
+
command: 401,
|
|
99
|
+
error: 0,
|
|
100
|
+
length: "0007",
|
|
101
|
+
method: 0,
|
|
102
|
+
payload: "1;2;3;4;5;6;7;8;9;10;11;12;13",
|
|
103
|
+
portA_antenna: 4,
|
|
104
|
+
portA_band: 2,
|
|
105
|
+
portA_inhibit: 3,
|
|
106
|
+
portA_mode: 1,
|
|
107
|
+
portA_profile: 5,
|
|
108
|
+
portA_tx: 6,
|
|
109
|
+
portB_antenna: 10,
|
|
110
|
+
portB_band: 8,
|
|
111
|
+
portB_inhibit: 9,
|
|
112
|
+
portB_mode: 7,
|
|
113
|
+
portB_profile: 11,
|
|
114
|
+
portB_tx: 12,
|
|
115
|
+
protocol: 0,
|
|
116
|
+
revision: 0,
|
|
117
|
+
stackReach: 13,
|
|
118
|
+
});
|
|
119
|
+
done();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should decode 412 input correctly", (done) => {
|
|
123
|
+
let command = encode(0, 0, 412, 0, "") + "1;Name;3;FFFF";
|
|
124
|
+
let data = decode(command);
|
|
125
|
+
expect(data).toBeDefined();
|
|
126
|
+
expect(data).toStrictEqual({
|
|
127
|
+
bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
128
|
+
command: 412,
|
|
129
|
+
error: 0,
|
|
130
|
+
index: 1,
|
|
131
|
+
length: "0007",
|
|
132
|
+
method: 0,
|
|
133
|
+
mode: 3,
|
|
134
|
+
name: "Name",
|
|
135
|
+
payload: "1;Name;3;FFFF",
|
|
136
|
+
protocol: 0,
|
|
137
|
+
revision: 0,
|
|
138
|
+
});
|
|
139
|
+
done();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -4,85 +4,123 @@ const serverNode = require("../antenna-genius-server.js");
|
|
|
4
4
|
|
|
5
5
|
const nodes = [activateAntennaNode, serverNode];
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
describe("antenna-genius-activate-antenna Node", () => {
|
|
8
|
+
const flow = [
|
|
9
|
+
{
|
|
10
|
+
id: "n1",
|
|
11
|
+
type: "antenna-genius-server",
|
|
12
|
+
name: "test name",
|
|
13
|
+
hostname: "localhost",
|
|
14
|
+
port: 9007,
|
|
15
|
+
disabledColor: "Black",
|
|
16
|
+
activeColor: "Green",
|
|
17
|
+
selectedColor: "Blue",
|
|
18
|
+
autoConnect: false,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "n2",
|
|
22
|
+
type: "antenna-genius-activate-antenna",
|
|
23
|
+
name: "test name",
|
|
24
|
+
server: "n1",
|
|
25
|
+
wires: [["n3"]],
|
|
26
|
+
},
|
|
27
|
+
{ id: "n3", type: "helper" },
|
|
28
|
+
];
|
|
13
29
|
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
});
|
|
30
|
+
beforeEach(() => {});
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
helper.unload();
|
|
34
|
+
});
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
it('should have properties', done => {
|
|
30
|
-
helper.load(nodes, flow, () => {
|
|
31
|
-
let n2 = helper.getNode("n2");
|
|
32
|
-
expect(n2).toHaveProperty('name', 'test name');
|
|
33
|
-
done();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
+
it("should be loaded", (done) => {
|
|
37
|
+
helper.load(nodes, flow, () => {
|
|
38
|
+
let n2 = helper.getNode("n2");
|
|
39
|
+
expect(n2).toBeDefined();
|
|
40
|
+
done();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
44
|
+
it("should have properties", (done) => {
|
|
45
|
+
helper.load(nodes, flow, () => {
|
|
46
|
+
let n2 = helper.getNode("n2");
|
|
47
|
+
expect(n2).toHaveProperty("name", "test name");
|
|
48
|
+
done();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
52
|
+
it("should not provide connected status", (done) => {
|
|
53
|
+
helper.load(nodes, flow, () => {
|
|
54
|
+
let n2 = helper.getNode("n2");
|
|
55
|
+
n2.server.updatesEventEmitter.emit("connected");
|
|
56
|
+
expect(n2.status.notCalled).toBeTruthy();
|
|
57
|
+
done();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
it("should provide connected status", (done) => {
|
|
62
|
+
helper.load(nodes, flow, () => {
|
|
63
|
+
let n2 = helper.getNode("n2");
|
|
64
|
+
n2.server.info = { name: "Name" };
|
|
65
|
+
n2.server.updatesEventEmitter.emit("connected");
|
|
66
|
+
expect(
|
|
67
|
+
n2.status.calledOnceWithExactly({
|
|
68
|
+
fill: "green",
|
|
69
|
+
shape: "dot",
|
|
70
|
+
text: "Name",
|
|
71
|
+
})
|
|
72
|
+
).toBeTruthy();
|
|
73
|
+
done();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
it("should provide disconnected status", (done) => {
|
|
78
|
+
helper.load(nodes, flow, () => {
|
|
79
|
+
let n2 = helper.getNode("n2");
|
|
80
|
+
n2.server.info = { name: "Name" };
|
|
81
|
+
n2.server.updatesEventEmitter.emit("closed");
|
|
82
|
+
expect(
|
|
83
|
+
n2.status.calledOnceWithExactly({
|
|
84
|
+
fill: "red",
|
|
85
|
+
shape: "ring",
|
|
86
|
+
text: "disconnected",
|
|
87
|
+
})
|
|
88
|
+
).toBeTruthy();
|
|
89
|
+
done();
|
|
74
90
|
});
|
|
75
|
-
|
|
76
|
-
});
|
|
91
|
+
});
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
it("should provide for invalid input", (done) => {
|
|
94
|
+
helper.load(nodes, flow, () => {
|
|
95
|
+
let n2 = helper.getNode("n2");
|
|
96
|
+
n2.server.info = { name: "Name" };
|
|
97
|
+
n2.receive({ payload: true });
|
|
98
|
+
n2.on("call:status", (call) => {
|
|
99
|
+
expect(
|
|
100
|
+
n2.status.calledOnceWithExactly({
|
|
101
|
+
fill: "red",
|
|
102
|
+
shape: "ring",
|
|
103
|
+
text: "topic is not set",
|
|
104
|
+
})
|
|
105
|
+
).toBeTruthy();
|
|
106
|
+
done();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
87
110
|
|
|
88
|
-
|
|
111
|
+
it("should provide for valid input", (done) => {
|
|
112
|
+
helper.load(nodes, flow, () => {
|
|
113
|
+
let n2 = helper.getNode("n2");
|
|
114
|
+
n2.server.info = { name: "Name" };
|
|
115
|
+
n2.receive({ payload: true, topic: "1;1" });
|
|
116
|
+
expect(
|
|
117
|
+
n2.status.calledOnceWithExactly({
|
|
118
|
+
fill: "green",
|
|
119
|
+
shape: "dot",
|
|
120
|
+
text: "Name",
|
|
121
|
+
})
|
|
122
|
+
).toBeTruthy();
|
|
123
|
+
done();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|