Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _spec.js in Create Your First Node #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions docs/creating-nodes/first-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,32 +192,40 @@ Using this framework, you can create test flows, and then assert that your node

```javascript
var should = require("should");
var helper = require("node-red-test-helper");
var helper = require("node-red-node-test-helper");
var lowerNode = require("../lower-case.js");

describe('lower-case Node', function () {
helper.init(require.resolve("node-red"));

afterEach(function () {
describe("lower-case Node", function() {
beforeEach(function(done) {
helper.startServer(done);
});

afterEach(function(done) {
helper.unload();
helper.stopServer(done);
});

it('should be loaded', function (done) {
var flow = [{ id: "n1", type: "lower-case", name: "test name" }];
helper.load(lowerNode, flow, function () {
it("should be loaded", function(done) {
var flow = [{ id: "n1", type: "lower-case", name: "lower-case" }];
helper.load(lowerNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', 'test name');
n1.should.have.property("name", "lower-case");
done();
});
});

it('should make payload lower case', function (done) {
var flow = [{ id: "n1", type: "lower-case", name: "test name",wires:[["n2"]] },
{ id: "n2", type: "helper" }];
helper.load(lowerNode, flow, function () {
it("should make payload lower case", function(done) {
var flow = [
{ id: "n1", type: "lower-case", name: "lower-case", wires: [["n2"]] },
{ id: "n2", type: "helper" },
];
helper.load(lowerNode, flow, function() {
var n2 = helper.getNode("n2");
var n1 = helper.getNode("n1");
n2.on("input", function (msg) {
msg.should.have.property('payload', 'uppercase');
n2.on("input", function(msg) {
msg.should.have.property("payload", "uppercase");
done();
});
n1.receive({ payload: "UpperCase" });
Expand Down