@gregoriusrippenstein/erlang-red-unittest 0.10.9 → 0.11.0

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.
@@ -7,7 +7,7 @@
7
7
  "succeed": "assert succeed",
8
8
  "count": "Msg Count",
9
9
  "unsupported": "Unsupported",
10
- "failed": "assert Failed"
10
+ "failed": "assert failed"
11
11
  },
12
12
 
13
13
  "status": {
@@ -18,7 +18,11 @@
18
18
  value:"",
19
19
  },
20
20
  count: {
21
- value: 1
21
+ value: 1,
22
+ required: true,
23
+ validate: function(v) {
24
+ return v == "" || parseInt(v) > 0
25
+ }
22
26
  }
23
27
  },
24
28
 
@@ -28,7 +32,14 @@
28
32
  outputs: 0,
29
33
 
30
34
  label: function() {
31
- return (this.name || this._def.paletteLabel);
35
+ let label = `${this.name || this._def.paletteLabel}`
36
+
37
+ if ( this.count == "") { this.count = 1 }
38
+
39
+ if ( this.count > 1 ) {
40
+ label = `${label}: ${this.count}`
41
+ }
42
+ return label;
32
43
  },
33
44
 
34
45
  labelStyle: function() {
@@ -36,18 +47,21 @@
36
47
  },
37
48
 
38
49
  onpaletteadd: function() {
50
+ if (!this.count || this.count == "") { this.count = 1 }
39
51
  },
40
52
 
41
53
  onpaletteremove: function() {
42
54
  },
43
55
 
44
56
  oneditprepare: function() {
57
+ if (!this.count || this.count == "") { this.count = 1 }
45
58
  },
46
59
 
47
60
  oneditcancel: function() {
48
61
  },
49
62
 
50
63
  oneditsave: function() {
64
+ if (!this.count || this.count == "") { this.count = 1 }
51
65
  },
52
66
 
53
67
  oneditresize: function(size) {
@@ -5,52 +5,23 @@ module.exports = function(RED) {
5
5
  var node = this;
6
6
  var cfg = config;
7
7
 
8
-
9
- var sendToDebug = (nde, rule, msgc, lvl) => {
10
- try {
11
- let msg = {
12
- id: nde.id,
13
- z: nde.z,
14
- _alias: nde._alias,
15
- path: nde._flow.path,
16
- name: nde.name,
17
- topic: msgc.topic,
18
- msg: { msg: msgc, rule: rule },
19
- level: lvl
20
- }
21
-
22
- msg = RED.util.encodeObject(msg);
23
- RED.comms.publish("debug", msg);
24
- } catch (ex) {
25
- console.error(ex)
26
- }
27
- return ["failure", rule];
28
- }
29
-
30
- var postUnsupported = (rule, msg) => {
31
- node.status({
32
- fill: "red", shape: "dot",
33
- text: RED._("ut-assert-success.label.unsupported", { property: JSON.stringify(rule) })
34
- });
35
- sendToDebug(node, rule, msg, 30)
36
-
37
- return ["unsupported", rule]
38
- }
39
-
40
-
41
8
  node.on('close', function() {
9
+ node.context().set("msgcnt", 0)
42
10
  node.status({});
43
11
  });
44
12
 
45
13
  /* msg handler, in this case pass the message on unchanged */
46
14
  node.on("input", function(msg, send, done) {
15
+ let msgcnt = (node.context().get("msgcnt") || 0) + 1;
16
+ node.context().set("msgcnt", msgcnt)
17
+
47
18
  // How to send a status update
48
- if ( cfg.count == 1) {
19
+ if ( (cfg.count || 1) == msgcnt) {
49
20
  node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-success.label.succeed") });
50
21
  } else {
51
- postUnsupported("count != 1", msg)
52
- node.status({ fill: "red", shape: "ring", text: RED._("ut-assert-success.label.failed") });
22
+ node.status({ fill: "red", shape: "ring", text: RED._("ut-assert-success.label.failed") + `: ${cfg.count} != ${msgcnt}`});
53
23
  }
24
+
54
25
  // Send a message and how to handle errors.
55
26
  try {
56
27
  try {
@@ -52,6 +52,7 @@ module.exports = function(RED) {
52
52
  }
53
53
 
54
54
  node.on('close', function() {
55
+ node.context().set("succeed", false)
55
56
  node.status({});
56
57
  });
57
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/erlang-red-unittest",
3
- "version": "0.10.9",
3
+ "version": "0.11.0",
4
4
  "dependencies": {
5
5
  },
6
6