@gregoriusrippenstein/erlang-red-unittest 0.11.3 → 0.11.4
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/README.md +4 -4
- package/nodes/ut-assert-values.html +2 -0
- package/nodes/ut-assert-values.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
## Unit testing nodes for Erlang-RED
|
|
2
2
|
|
|
3
|
-
Node-RED Nodes for testing flow correctness in the [Erlang-
|
|
3
|
+
Node-RED Nodes for testing flow correctness in the [Erlang-Red](https://github.com/gorenje/erlang-red) project.
|
|
4
4
|
|
|
5
|
-
These
|
|
5
|
+
These nodes provide the basis for the *unofficial* [Visual Unit Testing Suite (VUTS)](https://github.com/gorenje/erlang-red-flow-testsuite) for Node-RED. The test-suite aims to create a collection of visual unit tests for regression testing of existing behaviour. However the test-suite also provides a proof of correctness for projects that emulate Node-RED behaviour, for example [Erlang-Red](https://github.com/gorenje/erlang-red).
|
|
6
|
+
|
|
7
|
+
Thus if others wish to implement a Node-RED engine in their favourite language, then implementing these nodes first and then loading this test-suite will provide a good roadmap for further development. For example.
|
|
6
8
|
|
|
7
9
|
## Assert Nodes
|
|
8
10
|
|
|
@@ -34,5 +36,3 @@ These nodes have been published because the [Erlang-RED flow testsuite](https://
|
|
|
34
36
|
- [Node-RED node package](https://flows.nodered.org/node/@gregoriusrippenstein/erlang-red-unittest)
|
|
35
37
|
- [GitHub Repo](https://github.com/gorenje/erlang-red-unittesting-nodes)
|
|
36
38
|
- Node-RED flow that maintains this [codebase](https://flowhub.org/f/ef91cb280e1bfd72).
|
|
37
|
-
|
|
38
|
-
|
|
@@ -58,9 +58,11 @@
|
|
|
58
58
|
if ( this.rules) {
|
|
59
59
|
if (this.rules.length == 1) {
|
|
60
60
|
let lbl = this._("ut-assert-values.label." + this.rules[0].t, { property: prop2name((this.rules[0].pt || "msg"), this.rules[0].p) });
|
|
61
|
+
|
|
61
62
|
if (["num","bool"].includes(this.rules[0].tot)) {
|
|
62
63
|
lbl += " to " + this.rules[0].to
|
|
63
64
|
}
|
|
65
|
+
|
|
64
66
|
return lbl;
|
|
65
67
|
} else {
|
|
66
68
|
return this._("ut-assert-values.label.changeCount", { count: this.rules.length });
|
|
@@ -92,8 +92,15 @@ module.exports = function(RED) {
|
|
|
92
92
|
} else if (rule.tot == "json") {
|
|
93
93
|
let expObj = JSON.parse(rule.to)
|
|
94
94
|
let oldObj = RED.util.getObjectProperty(msg, rule.p)
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
|
|
96
|
+
if ( Array.isArray(expObj)) {
|
|
97
|
+
if (JSON.stringify(oldObj) != JSON.stringify(expObj)) {
|
|
98
|
+
failures.push(sendToDebug(node, rule, msg, 20))
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
if ( JSON.stringify(oldObj, Object.keys(oldObj).sort()) != JSON.stringify(expObj, Object.keys(expObj).sort()) ) {
|
|
102
|
+
failures.push(sendToDebug(node, rule, msg, 20))
|
|
103
|
+
}
|
|
97
104
|
}
|
|
98
105
|
} else if (rule.tot == "msg") {
|
|
99
106
|
if ( RED.util.getObjectProperty(msg,rule.to) != RED.util.getObjectProperty(msg,rule.p) ) {
|