How to use the node-red-node-test-helper.getNode function in node-red-node-test-helper

To help you get started, we’ve selected a few node-red-node-test-helper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / node-red-contrib-google-cloud / tests / sentiment_node_spec.js View on Github external
helper.load(sentimentNode, flow, () => {
            // At this point the flow is "running".  We now need to send in some data.
            const n1 = helper.getNode("n1");
            const n2 = helper.getNode("n2");
            n2.on('input', (msg) => {
                msg.sentiment.score.should.be.above(0.5);
                done();
            });
            n1.receive({payload: "This is great!"});
        });
    });
github GoogleCloudPlatform / node-red-contrib-google-cloud / tests / sentiment_node_spec.js View on Github external
helper.load(sentimentNode, flow, () => {
            // At this point the flow is "running".  We now need to send in some data.
            const n1 = helper.getNode("n1");
            const n2 = helper.getNode("n2");
            n2.on('input', (msg) => {
                msg.sentiment.score.should.be.above(0.5);
                done();
            });
            n1.receive({payload: "This is great!"});
        });
    });
github GoogleCloudPlatform / node-red-contrib-google-cloud / tests / pubsub_in_node_spec.js View on Github external
helper.load(pubsubInNode, flow, () => {
            // At this point the flow is "running".  We now need to send in some data.
            const n1 = helper.getNode("n1");
            const n2 = helper.getNode("n2");
            const text = "Hello World!"; // The message we publish which should be received by the flow.
            n2.on('input', (msg) => {
                msg.should.have.property('payload');  // Check that we have msg.payload 
                msg.should.have.property('message');  // Check that we have msg.message 
                msg.payload.toString().should.be.equal(text);
                done();
            });
            // Publish a message using the API which should now wake us up.
            const topic = pubsub.topic('node-red-topic');
            topic.publish(Buffer.from(text));
        });
    });
github node-red / node-red-nodes / test / parsers / msgpack / 70-msgpack_spec.js View on Github external
helper.load(testNode, flow, function() {
            var n1 = helper.getNode("n1");
            var n2 = helper.getNode("n2");
            n2.on("input", function(msg) {
                msg.should.have.a.property("payload");
                msg.payload.should.be.a.Object;
                msg.payload.should.have.length(43);
                buf = msg.payload;
                done();
            });
            n1.emit("input", {payload:{A:1, B:"string", C:true, D:[1,true,"string"], E:{Y:9,Z:"string"}}});
        });
    });
github node-red / node-red-nodes / test / function / random / random_spec.js View on Github external
helper.load(testNode, flow, function() {
            var n1 = helper.getNode("n1");
            var n2 = helper.getNode("n2");
            var c = 0;
            n2.on("input", function(msg) {
                if (c === 0) {
                    msg.should.have.a.property("payload");
                    msg.payload.should.be.approximately(0,3);
                    msg.payload.toString().indexOf(".").should.equal(-1);
                    done();
                }
            });
            n1.emit("input", {payload:"a"});
        });
    });
github node-red / node-red / test / nodes / core / parsers / 70-XML_spec.js View on Github external
helper.load(xmlNode, flow, function() {
            var n1 = helper.getNode("n1");
            var n2 = helper.getNode("n2");
            n2.on("input", function(msg) {
                msg.should.have.property('topic', 'bar');
                msg.payload.should.have.property('employees');
                msg.payload.employees.should.have.property('firstName');
                should.equal(msg.payload.employees.firstName[0], 'John');
                msg.payload.employees.should.have.property('lastName');
                should.equal(msg.payload.employees.lastName[0], 'Smith');
                done();
            });
            var string = 'JohnSmith';
            n1.receive({payload:string,topic: "bar"});
        });
    });
github node-red / node-red / test / nodes / core / hardware / 36-rpi-gpio_spec.js View on Github external
helper.load([rpiNode,statusNode], flow, function() {
            var n1 = helper.getNode("n1");
            var n2 = helper.getNode("n2");
            var n3 = helper.getNode("n3");
            n3.on("input", function(msg) {
                try {
                    msg.should.have.property('status');
                    msg.status.should.have.property('text', "rpi-gpio.status.na");
                    done();
                } catch(err) {
                    done(err);
                }
            });
            n1.receive({payload:"1"});
        });
    });
github node-red / node-red / test / nodes / subflow / subflow_spec.js View on Github external
helper.load(functionNode, flow, function() {
            var n1 = helper.getNode("n1");
            var n2 = helper.getNode("n2");
            n2.on("input", function(msg) {
                msg.should.have.property("payload", "foobar");
                done();
            });
            n1.receive({payload:"foo"});
        });
    });
github node-red / node-red / test / nodes / core / parsers / 70-HTML_spec.js View on Github external
helper.load(htmlNode, flow, function() {
                var n1 = helper.getNode("n1");
                var n2 = helper.getNode("n2");
                n2.on("input", function(msg) {
                    msg.should.have.property('topic', 'bar');
                    should.equal(msg.payload, 'This is a test page for node 70-HTML');
                    done();
                });
                n1.receive({payload:data,topic:"bar",select:"h1"});
            });
        });
github node-red / node-red-nodes / test / social / feedparse / 32-feedparse_spec.js View on Github external
helper.load(feedParserNode, flow, () => {
            const n2 = helper.getNode("n2");
            const n1 = helper.getNode("n1");
            let count = 0;
            n2.on("input", (msg) => {
                msg.topic.should.startWith("https://discourse.nodered.org/");
                if(count === 0){
                    done();
                    count++;
                }
            });
        });
    });

node-red-node-test-helper

A test framework for Node-RED nodes

Apache-2.0
Latest version published 7 months ago

Package Health Score

77 / 100
Full package analysis