mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Initial test build framework for node-red-nodes
This commit is contained in:
parent
903bbe505a
commit
24394c4b18
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,5 @@
|
||||
npm-debug.log
|
||||
node_modules
|
||||
.npm
|
||||
coverage
|
||||
coverall
|
||||
|
13
.travis.yml
Normal file
13
.travis.yml
Normal file
@ -0,0 +1,13 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
before_install:
|
||||
- npm install -g npm@~1.4.18
|
||||
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 )
|
||||
script:
|
||||
- istanbul cover ./node_modules/.bin/grunt --report lcovonly && istanbul report text && ( cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js || true ) && rm -rf coverage
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2013, 2014 IBM Corp.
|
||||
* Copyright 2015 IBM Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -15,7 +15,6 @@
|
||||
**/
|
||||
|
||||
module.exports = function(grunt) {
|
||||
"use strict";
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
@ -27,7 +26,7 @@ module.exports = function(grunt) {
|
||||
ui: 'bdd',
|
||||
reporter: 'spec'
|
||||
},
|
||||
all: { src: ['./*_spec.js'] },
|
||||
all: { src: ['test/*/*/*_spec.js'] },
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
@ -43,14 +42,24 @@ module.exports = function(grunt) {
|
||||
"sub": true // don't warn that foo['bar'] should be written as foo.bar
|
||||
},
|
||||
all: {
|
||||
src: ['../../../utility/exif/*.js']
|
||||
src: ['*/*.js'],
|
||||
filter: function(filepath) { // on some developer machines the test coverage HTML report utilities cause further failures
|
||||
if(filepath.indexOf("coverage/prettify.js") === -1) {
|
||||
return true;
|
||||
} else {
|
||||
console.log("Filtered out " + filepath + " from the jshint checks");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
inlinelint: {
|
||||
html: ['*/*.html']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-simple-mocha');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-lint-inline');
|
||||
|
||||
grunt.registerTask('default', ['jshint:all', 'simplemocha:all']);
|
||||
grunt.registerTask('default', ['jshint:all', 'simplemocha:all'] );
|
||||
};
|
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name" : "node-red-nodes",
|
||||
"version" : "0.0.1",
|
||||
"description" : "Node-RED-nodes package to hold the test framework ONLY - use npm to install individual nodes",
|
||||
"homepage" : "http://nodered.org",
|
||||
"license" : "Apache",
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
"url":"https://github.com/node-red/node-red-nodes.git"
|
||||
},
|
||||
"contributors": [
|
||||
{"name": "Dave Conway-Jones"},
|
||||
{"name": "Nick O'Leary"}
|
||||
],
|
||||
"keywords": [
|
||||
"Node-RED", "nodes", "iot", "ibm", "flow"
|
||||
],
|
||||
"devDependencies": {
|
||||
"grunt": "0.4.5",
|
||||
"grunt-cli": "0.1.13",
|
||||
"grunt-simple-mocha": "0.4.0",
|
||||
"grunt-contrib-jshint": "0.11.0",
|
||||
"mocha": "2.1.0",
|
||||
"should": "4.6.5",
|
||||
"sinon": "1.12.2",
|
||||
"supertest": "0.15.0",
|
||||
"proxyquire": "1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8 <0.11"
|
||||
}
|
||||
}
|
31
test/helper.js
Normal file
31
test/helper.js
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2014 IBM Corp.
|
||||
*
|
||||
* 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');
|
||||
|
||||
//console.log("WAS",process.env.NODE_RED_HOME);
|
||||
//console.log("WAS2",__dirname);
|
||||
process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/../../node-red");
|
||||
//console.log("HOME",process.env.NODE_RED_HOME);
|
||||
//console.log("PATH",path.join(process.env.NODE_RED_HOME, 'test', 'nodes', 'helper.js'));
|
||||
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;
|
@ -20,22 +20,26 @@ var sinon = require('sinon');
|
||||
var should = require("should");
|
||||
var proxyquire = require("proxyquire");
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var util = require('util');
|
||||
var data = require("./data");
|
||||
var path = require("path");
|
||||
var helper = require('../../../test/helper.js');
|
||||
|
||||
// Mute "Starting/Stopping flows to stdout"
|
||||
var util = require('util');
|
||||
var flows = proxyquire('../../../.node-red/red/nodes/flows.js', {
|
||||
util: {
|
||||
log: function(msg) {
|
||||
if(!/ing flows/.test(msg)) {
|
||||
util.log(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var helper = require('../../../.node-red/test/nodes/helper.js');
|
||||
//var flows = proxyquire('../../../.node-red/red/nodes/flows.js', {
|
||||
//var flows = proxyquire('../../../../../red/nodes/flows.js', {
|
||||
//util: {
|
||||
//log: function(msg) {
|
||||
//if(!/ing flows/.test(msg)) {
|
||||
//util.log(msg);
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//});
|
||||
|
||||
//var helper = require('../../../.node-red/test/nodes/helper.js');
|
||||
//var helper = require('../../../../../test/nodes/helper.js');
|
||||
|
||||
var currentPB = null;
|
||||
var pushbulletStub = function() {
|
||||
|
@ -17,11 +17,9 @@
|
||||
var should = require("should");
|
||||
var sinon = require('sinon');
|
||||
var fs = require("fs");
|
||||
|
||||
var helper = require('../../../test/helper.js');
|
||||
var exifNode = require("../../../utility/exif/94-exif.js");
|
||||
|
||||
var helper = require('../../../../node-red/test/nodes/helper.js');
|
||||
|
||||
describe('exif node', function() {
|
||||
"use strict";
|
||||
|
||||
@ -35,17 +33,16 @@ describe('exif node', function() {
|
||||
});
|
||||
|
||||
it('extracts location data from Exif data of JPEG', function(done) {
|
||||
|
||||
var exif = require('exif');
|
||||
var ExifImage = exif.ExifImage;
|
||||
|
||||
// the jpg file is a single black dot but it was originally a photo taken at IBM Hursley
|
||||
var data = fs.readFileSync("./exif_test_image.jpg", null); // extracting genuine exif data to be fed back as the result of the stubbed ExifImage constructor
|
||||
var data = fs.readFileSync("test/utility/exif/exif_test_image.jpg", null); // extracting genuine exif data to be fed back as the result of the stubbed ExifImage constructor
|
||||
|
||||
var eD;
|
||||
|
||||
new ExifImage({ image : data }, function (error, exifData) {
|
||||
if(error) {
|
||||
if (error) {
|
||||
done(error);
|
||||
} else {
|
||||
eD = exifData;
|
||||
|
Loading…
Reference in New Issue
Block a user