node-red-contrib-antenna-genius 0.2.3-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 +36 -17
- package/antenna-genius-antenna-status.html +29 -18
- package/antenna-genius-antenna-status.js +66 -29
- package/antenna-genius-band-labels.html +14 -12
- package/antenna-genius-band-labels.js +41 -18
- package/antenna-genius-server.html +35 -21
- package/antenna-genius-server.js +43 -25
- 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
|
@@ -3,43 +3,49 @@ module.exports = (RED) => {
|
|
|
3
3
|
constructor(config) {
|
|
4
4
|
RED.nodes.createNode(this, config);
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let node = this;
|
|
7
7
|
this.bandNameA = "";
|
|
8
8
|
this.bandNameB = "";
|
|
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
|
-
this.server.updatesEventEmitter.on("status", () => {
|
|
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
|
-
let changed =
|
|
48
|
+
let changed = forceUpdate;
|
|
43
49
|
if (bandNameA !== this.bandNameA) {
|
|
44
50
|
changed = true;
|
|
45
51
|
this.bandNameA = 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
|
|
|
@@ -22,6 +22,7 @@ module.exports = (RED) => {
|
|
|
22
22
|
this.bands = [];
|
|
23
23
|
this.interval = null;
|
|
24
24
|
this.timer = null;
|
|
25
|
+
this.refresh = -1;
|
|
25
26
|
|
|
26
27
|
this.updatesEventEmitter = new UpdatesEventEmitter();
|
|
27
28
|
this.updatesEventEmitter.setMaxListeners(0);
|
|
@@ -29,30 +30,34 @@ module.exports = (RED) => {
|
|
|
29
30
|
this.client = new Net.Socket();
|
|
30
31
|
this.connected = false;
|
|
31
32
|
|
|
32
|
-
this.client.on(
|
|
33
|
-
this.log(
|
|
33
|
+
this.client.on("close", () => {
|
|
34
|
+
this.log("TCP connection disconnected with the server.");
|
|
34
35
|
clearInterval(this.interval);
|
|
35
36
|
clearTimeout(this.timer);
|
|
36
37
|
|
|
37
|
-
if(this.updatesEventEmitter.listenerCount(
|
|
38
|
-
this.log(
|
|
38
|
+
if (this.updatesEventEmitter.listenerCount("closed") == 0) {
|
|
39
|
+
this.log(
|
|
40
|
+
"Stop retrying. No nodes are refering this connection anymore."
|
|
41
|
+
);
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
if(this.autoConnect) {
|
|
43
|
-
this.log(
|
|
45
|
+
if (this.autoConnect) {
|
|
46
|
+
this.log(
|
|
47
|
+
"TCP connection failed with the server. Will try to reconnect in 5 seconds"
|
|
48
|
+
);
|
|
44
49
|
this.timer = setTimeout(() => {
|
|
45
|
-
this.log(
|
|
50
|
+
this.log("Reconnecting...");
|
|
46
51
|
this.connect();
|
|
47
52
|
}, 5000);
|
|
48
53
|
this.updatesEventEmitter.emit("closed");
|
|
49
54
|
}
|
|
50
55
|
});
|
|
51
56
|
|
|
52
|
-
this.client.on(
|
|
53
|
-
this.log(
|
|
57
|
+
this.client.on("connect", async () => {
|
|
58
|
+
this.log("TCP connection established with the server.");
|
|
54
59
|
this.connected = true;
|
|
55
|
-
|
|
60
|
+
|
|
56
61
|
const promiseClient = new PromiseSocket(this.client);
|
|
57
62
|
|
|
58
63
|
let command = Utils.encode(0, 0, 401, 0, "");
|
|
@@ -65,7 +70,7 @@ module.exports = (RED) => {
|
|
|
65
70
|
packet = await promiseClient.read();
|
|
66
71
|
this.info = Utils.decode(packet);
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
let numAntennas = 8 * this.status.stackReach;
|
|
69
74
|
for (let index = 1; index <= numAntennas; ++index) {
|
|
70
75
|
let command = Utils.encode(0, 0, 412, 0, index.toString());
|
|
71
76
|
await promiseClient.write(command);
|
|
@@ -84,11 +89,18 @@ module.exports = (RED) => {
|
|
|
84
89
|
}
|
|
85
90
|
this.updatesEventEmitter.emit("bands");
|
|
86
91
|
|
|
87
|
-
this.client.on(
|
|
92
|
+
this.client.on("data", (packet) => {
|
|
88
93
|
let decoded = Utils.decode(packet);
|
|
89
|
-
if(decoded.command == 401) {
|
|
90
|
-
this.status = {
|
|
91
|
-
|
|
94
|
+
if (decoded.command == 401) {
|
|
95
|
+
this.status = {
|
|
96
|
+
...this.status,
|
|
97
|
+
...Utils.decode(packet),
|
|
98
|
+
};
|
|
99
|
+
this.refresh = (this.refresh + 1) % 1500;
|
|
100
|
+
this.updatesEventEmitter.emit(
|
|
101
|
+
"status",
|
|
102
|
+
this.refresh == 0
|
|
103
|
+
);
|
|
92
104
|
}
|
|
93
105
|
});
|
|
94
106
|
|
|
@@ -98,29 +110,35 @@ module.exports = (RED) => {
|
|
|
98
110
|
this.client.write(command);
|
|
99
111
|
}, 400);
|
|
100
112
|
|
|
113
|
+
this.forceUpdate();
|
|
101
114
|
this.updatesEventEmitter.emit("connected");
|
|
102
|
-
})
|
|
115
|
+
});
|
|
103
116
|
|
|
104
|
-
this.client.on(
|
|
117
|
+
this.client.on("error", (err) => {
|
|
105
118
|
this.warn(err);
|
|
106
119
|
});
|
|
107
120
|
|
|
108
|
-
this.on(
|
|
121
|
+
this.on("close", (done) => {
|
|
109
122
|
clearInterval(this.interval);
|
|
110
123
|
clearTimeout(this.timer);
|
|
111
124
|
this.autoConnect = false;
|
|
112
125
|
this.connected = false;
|
|
113
126
|
this.client.end();
|
|
127
|
+
this.forceUpdate();
|
|
114
128
|
done();
|
|
115
129
|
});
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
connect() {
|
|
119
|
-
if(this.autoConnect && !this.connected & !this.client.connecting) {
|
|
133
|
+
if (this.autoConnect && !this.connected & !this.client.connecting) {
|
|
120
134
|
this.client.connect(this.port, this.host);
|
|
121
135
|
}
|
|
122
136
|
}
|
|
137
|
+
|
|
138
|
+
forceUpdate() {
|
|
139
|
+
this.refresh = -1;
|
|
140
|
+
}
|
|
123
141
|
}
|
|
124
142
|
|
|
125
|
-
RED.nodes.registerType("antenna-genius-server",AntennaGeniusServerNode);
|
|
126
|
-
}
|
|
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
|
-
var 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
|
+
});
|