Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated nodes
node-red-contrib-*
node-red-node-*
nodegen

# Dependency directory
node_modules
Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ script:
before_script:
- npm install -g istanbul
- npm install coveralls
- npm install git+https://github.com/node-red/node-red.git
- export NODE_RED_HOME=`pwd`/node_modules/node-red
- (cd $NODE_RED_HOME ; npm install nock@~0.48.0)
- mkdir nodegen
- node bin/node-red-nodegen.js samples/lower-case.js -o ./nodegen
- node bin/node-red-nodegen.js http://petstore.swagger.io/v2/swagger.json -o ./nodegen

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"grunt-simple-mocha": "0.4.1",
"grunt-mocha-istanbul": "5.0.2",
"should": "13.1.3",
"del": "3.0.0"
"sinon": "4.1.3",
"supertest": "3.0.0",
"del": "3.0.0",
"q": "1.5.1"
},
"bin": {
"node-red-nodegen": "./bin/node-red-nodegen.js"
Expand Down
28 changes: 28 additions & 0 deletions test/nodegen/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

var path = require('path');

process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/../../node-red");
var helper = require(path.join(process.env.NODE_RED_HOME, 'test', 'nodes', 'helper.js'));

try {
helper.nock = helper.nock || require("nock");
} catch(er) {
helper.nock = null;
}
module.exports = helper;

53 changes: 53 additions & 0 deletions test/nodegen/node-red-contrib-lowercase/node_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

var should = require("should");
var functionNode = require("../../../nodegen/node-red-contrib-lowercase/node.js");
var helper = require("../helper.js");

describe('node-red-contrib-lowercase', function () {

before(function (done) {
helper.startServer(done);
});

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

it('should be loaded', function (done) {
var flow = [{id: "n1", type: "lowercase", name: "lowercase" }];
helper.load(functionNode, flow, function () {
var n1 = helper.getNode('n1');
n1.should.have.property('name', 'lowercase');
done();
});
});
it('should handle toLowerCase()', function (done) {
var flow = [{id: "n1", type: "lowercase", wires: [["n2"]]},
{id: "n2", type: "helper"}];
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', 'abcde');
done();
});
n1.receive({payload: 'AbCdE'});
});
});
});

54 changes: 54 additions & 0 deletions test/nodegen/node-red-contrib-swagger-petstore/node_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

var should = require("should");
var swaggerNode = require("../../../nodegen/node-red-contrib-swagger-petstore/node.js");
var helper = require("../helper.js");

describe('node-red-contrib-swagger-petstore', function () {

before(function (done) {
helper.startServer(done);
});

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

it('should be loaded', function (done) {
var flow = [{id: "n1", type: "swagger-petstore", name: "swagger-petstore" }];
helper.load(swaggerNode, flow, function () {
var n1 = helper.getNode('n1');
n1.should.have.property('name', 'swagger-petstore');
done();
});
});
it('should handle getInventory()', function (done) {
var flow = [{id: "n1", type: "swagger-petstore", wires: [["n3"]], service: "n2", method: "getInventory"},
{id: "n2", type: "swagger-petstore-service"},
{id: "n3", type: "helper"}];
helper.load(swaggerNode, flow, function () {
var n1 = helper.getNode('n1');
var n3 = helper.getNode('n3');
n3.on('input', function (msg) {
msg.payload.should.have.property('123');
done();
});
n1.receive({});
});
});
});