@gregoriusrippenstein/erlang-red-unittest 0.10.8 → 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.
@@ -4,7 +4,10 @@
4
4
 
5
5
  "label": {
6
6
  "statusset": "Status Set",
7
- "succeed": "assert succeed"
7
+ "succeed": "assert succeed",
8
+ "count": "Msg Count",
9
+ "unsupported": "Unsupported",
10
+ "failed": "assert failed"
8
11
  },
9
12
 
10
13
  "status": {
@@ -17,6 +17,13 @@
17
17
  name: {
18
18
  value:"",
19
19
  },
20
+ count: {
21
+ value: 1,
22
+ required: true,
23
+ validate: function(v) {
24
+ return v == "" || parseInt(v) > 0
25
+ }
26
+ }
20
27
  },
21
28
 
22
29
  paletteLabel: "Assert True",
@@ -25,7 +32,14 @@
25
32
  outputs: 0,
26
33
 
27
34
  label: function() {
28
- 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;
29
43
  },
30
44
 
31
45
  labelStyle: function() {
@@ -33,18 +47,21 @@
33
47
  },
34
48
 
35
49
  onpaletteadd: function() {
50
+ if (!this.count || this.count == "") { this.count = 1 }
36
51
  },
37
52
 
38
53
  onpaletteremove: function() {
39
54
  },
40
55
 
41
56
  oneditprepare: function() {
57
+ if (!this.count || this.count == "") { this.count = 1 }
42
58
  },
43
59
 
44
60
  oneditcancel: function() {
45
61
  },
46
62
 
47
63
  oneditsave: function() {
64
+ if (!this.count || this.count == "") { this.count = 1 }
48
65
  },
49
66
 
50
67
  oneditresize: function(size) {
@@ -61,4 +78,9 @@
61
78
  <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
62
79
  <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
63
80
  </div>
81
+
82
+ <div class="form-row">
83
+ <label for="node-input-count" data-i18n="ut-assert-success.label.count"></label>
84
+ <input type="number" id="node-input-count" data-i18n="[placeholder]ut-assert-success.placeholder.count" style="width: 100px;"></input>
85
+ </div>
64
86
  </script>
@@ -6,14 +6,22 @@ module.exports = function(RED) {
6
6
  var cfg = config;
7
7
 
8
8
  node.on('close', function() {
9
+ node.context().set("msgcnt", 0)
9
10
  node.status({});
10
11
  });
11
12
 
12
13
  /* msg handler, in this case pass the message on unchanged */
13
14
  node.on("input", function(msg, send, done) {
14
- // How to send a status update
15
- node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-success.label.succeed") });
15
+ let msgcnt = (node.context().get("msgcnt") || 0) + 1;
16
+ node.context().set("msgcnt", msgcnt)
16
17
 
18
+ // How to send a status update
19
+ if ( (cfg.count || 1) == msgcnt) {
20
+ node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-success.label.succeed") });
21
+ } else {
22
+ node.status({ fill: "red", shape: "ring", text: RED._("ut-assert-success.label.failed") + `: ${cfg.count} != ${msgcnt}`});
23
+ }
24
+
17
25
  // Send a message and how to handle errors.
18
26
  try {
19
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.8",
3
+ "version": "0.11.0",
4
4
  "dependencies": {
5
5
  },
6
6