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
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -15,7 +15,6 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
@ -27,7 +26,7 @@ module.exports = function(grunt) {
|
|||||||
ui: 'bdd',
|
ui: 'bdd',
|
||||||
reporter: 'spec'
|
reporter: 'spec'
|
||||||
},
|
},
|
||||||
all: { src: ['./*_spec.js'] },
|
all: { src: ['test/*/*/*_spec.js'] },
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
options: {
|
options: {
|
||||||
@ -43,14 +42,24 @@ module.exports = function(grunt) {
|
|||||||
"sub": true // don't warn that foo['bar'] should be written as foo.bar
|
"sub": true // don't warn that foo['bar'] should be written as foo.bar
|
||||||
},
|
},
|
||||||
all: {
|
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-simple-mocha');
|
||||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
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 should = require("should");
|
||||||
var proxyquire = require("proxyquire");
|
var proxyquire = require("proxyquire");
|
||||||
var EventEmitter = require('events').EventEmitter
|
var EventEmitter = require('events').EventEmitter
|
||||||
|
var util = require('util');
|
||||||
var data = require("./data");
|
var data = require("./data");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
var helper = require('../../../test/helper.js');
|
||||||
|
|
||||||
// Mute "Starting/Stopping flows to stdout"
|
// 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 currentPB = null;
|
||||||
var pushbulletStub = function() {
|
var pushbulletStub = function() {
|
||||||
@ -91,7 +95,7 @@ var pushbulletNode = proxyquire("../../../social/pushbullet/57-pushbullet.js", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('pushbullet node', function() {
|
describe('pushbullet node', function() {
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
currentPB = new pushbulletStub();
|
currentPB = new pushbulletStub();
|
||||||
helper.startServer(done);
|
helper.startServer(done);
|
||||||
@ -221,7 +225,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}];
|
{id:"n3", type:"helper", wires: [["n2"]]}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "note");
|
var func = sinon.spy(currentPB, "note");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -236,7 +240,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title", chan: "mychannel"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title", chan: "mychannel"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}];
|
{id:"n3", type:"helper", wires: [["n2"]]}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "note");
|
var func = sinon.spy(currentPB, "note");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -251,7 +255,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}];
|
{id:"n3", type:"helper", wires: [["n2"]]}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "note");
|
var func = sinon.spy(currentPB, "note");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -267,7 +271,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "link", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "link", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}];
|
{id:"n3", type:"helper", wires: [["n2"]]}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "push");
|
var func = sinon.spy(currentPB, "push");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -285,7 +289,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "", title: ""},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "", title: ""},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}];
|
{id:"n3", type:"helper", wires: [["n2"]]}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "_msg_"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "_msg_"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "push");
|
var func = sinon.spy(currentPB, "push");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -306,7 +310,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "note", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "note");
|
var func = sinon.spy(currentPB, "note");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -322,7 +326,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "link", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "link", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "push");
|
var func = sinon.spy(currentPB, "push");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -339,7 +343,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "list", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "list", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "list");
|
var func = sinon.spy(currentPB, "list");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -357,7 +361,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "list", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "list", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "list");
|
var func = sinon.spy(currentPB, "list");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -375,7 +379,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "address", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "address", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "address");
|
var func = sinon.spy(currentPB, "address");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -391,7 +395,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "file", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "file", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "file");
|
var func = sinon.spy(currentPB, "file");
|
||||||
var fn = path.join(__dirname, "data.js")
|
var fn = path.join(__dirname, "data.js")
|
||||||
@ -408,10 +412,10 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "file", title: "title"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "file", title: "title"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "file");
|
var func = sinon.spy(currentPB, "file");
|
||||||
var errfn = sinon.spy(helper.getNode("n2"), "error");
|
var errfn = sinon.spy(helper.getNode("n2"), "error");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
payload: "hello",
|
payload: "hello",
|
||||||
});
|
});
|
||||||
@ -426,7 +430,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1"},
|
{id:"n2", type:"pushbullet", config: "n1"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "push");
|
var func = sinon.spy(currentPB, "push");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -443,7 +447,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1"},
|
{id:"n2", type:"pushbullet", config: "n1"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2: {deviceid: "id"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "updatePush");
|
var func = sinon.spy(currentPB, "updatePush");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -464,7 +468,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "delete"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "delete"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "deletePush");
|
var func = sinon.spy(currentPB, "deletePush");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -481,7 +485,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "dismissal"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "dismissal"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "updatePush");
|
var func = sinon.spy(currentPB, "updatePush");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -498,7 +502,7 @@ describe('pushbullet node', function() {
|
|||||||
{id:"n2", type:"pushbullet", config: "n1", pushtype: "updatelist"},
|
{id:"n2", type:"pushbullet", config: "n1", pushtype: "updatelist"},
|
||||||
{id:"n3", type:"helper", wires: [["n2"]]}
|
{id:"n3", type:"helper", wires: [["n2"]]}
|
||||||
];
|
];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
var func = sinon.spy(currentPB, "updatePush");
|
var func = sinon.spy(currentPB, "updatePush");
|
||||||
helper.getNode("n3").send({
|
helper.getNode("n3").send({
|
||||||
@ -517,7 +521,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
done();
|
done();
|
||||||
@ -530,7 +534,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
var func = sinon.spy(helper.getNode("n2"), 'status');
|
var func = sinon.spy(helper.getNode("n2"), 'status');
|
||||||
currentPB.streamEmitter.emit("connect");
|
currentPB.streamEmitter.emit("connect");
|
||||||
@ -545,7 +549,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "clip");
|
msg.should.have.property("pushtype", "clip");
|
||||||
@ -561,7 +565,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "mirror");
|
msg.should.have.property("pushtype", "mirror");
|
||||||
@ -577,7 +581,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "dismissal");
|
msg.should.have.property("pushtype", "dismissal");
|
||||||
@ -593,7 +597,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
var err = sinon.spy(helper.getNode("n1"), "error");
|
var err = sinon.spy(helper.getNode("n1"), "error");
|
||||||
currentPB.streamEmitter.emit("message", {type: "push", push: {type: "push", push: {type: "unknown", data: "test"}}});
|
currentPB.streamEmitter.emit("message", {type: "push", push: {type: "push", push: {type: "unknown", data: "test"}}});
|
||||||
@ -607,7 +611,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "note");
|
msg.should.have.property("pushtype", "note");
|
||||||
@ -626,7 +630,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "link");
|
msg.should.have.property("pushtype", "link");
|
||||||
@ -645,7 +649,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "address");
|
msg.should.have.property("pushtype", "address");
|
||||||
@ -664,7 +668,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "file");
|
msg.should.have.property("pushtype", "file");
|
||||||
@ -683,7 +687,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "list");
|
msg.should.have.property("pushtype", "list");
|
||||||
@ -702,7 +706,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "delete");
|
msg.should.have.property("pushtype", "delete");
|
||||||
@ -720,7 +724,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}}, function() {
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
msg.should.have.property("pushtype", "dismissal");
|
msg.should.have.property("pushtype", "dismissal");
|
||||||
@ -740,7 +744,7 @@ describe('pushbullet node', function() {
|
|||||||
var flow = [{id:"n1", type:"pushbullet-config"},
|
var flow = [{id:"n1", type:"pushbullet-config"},
|
||||||
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
{id:"n2", type:"pushbullet in", config: "n1", wires: [["n3"]]},
|
||||||
{id:"n3", type:"helper"}];
|
{id:"n3", type:"helper"}];
|
||||||
|
|
||||||
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2:{filters:['a', 'b']}}, function() {
|
helper.load(pushbulletNode, flow, {n1:{apikey:"invalid"}, n2:{filters:['a', 'b']}}, function() {
|
||||||
var counter = sinon.spy();
|
var counter = sinon.spy();
|
||||||
helper.getNode("n3").on("input", function(msg) {
|
helper.getNode("n3").on("input", function(msg) {
|
||||||
@ -748,7 +752,7 @@ describe('pushbullet node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var func = sinon.stub(currentPB, "history");
|
var func = sinon.stub(currentPB, "history");
|
||||||
|
|
||||||
currentPB.streamEmitter.emit("message", {type: "tickle", subtype: "push"});
|
currentPB.streamEmitter.emit("message", {type: "tickle", subtype: "push"});
|
||||||
var msg0 = getPushReply('link'); msg0.pushes[0].source_device_iden = 'a';
|
var msg0 = getPushReply('link'); msg0.pushes[0].source_device_iden = 'a';
|
||||||
func.onCall(0).yields(false, msg0);
|
func.onCall(0).yields(false, msg0);
|
||||||
@ -762,7 +766,7 @@ describe('pushbullet node', function() {
|
|||||||
func.onCall(2).yields(false, msg2);
|
func.onCall(2).yields(false, msg2);
|
||||||
|
|
||||||
currentPB.streamEmitter.emit("message", {type: "tickle", subtype: "push"});
|
currentPB.streamEmitter.emit("message", {type: "tickle", subtype: "push"});
|
||||||
var msg3 = getPushReply('link');
|
var msg3 = getPushReply('link');
|
||||||
delete msg3.pushes[0].source_device_iden;
|
delete msg3.pushes[0].source_device_iden;
|
||||||
delete msg3.pushes[0].target_device_iden;
|
delete msg3.pushes[0].target_device_iden;
|
||||||
func.onCall(3).yields(false, msg3);
|
func.onCall(3).yields(false, msg3);
|
||||||
|
@ -17,11 +17,9 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
var helper = require('../../../test/helper.js');
|
||||||
var exifNode = require("../../../utility/exif/94-exif.js");
|
var exifNode = require("../../../utility/exif/94-exif.js");
|
||||||
|
|
||||||
var helper = require('../../../../node-red/test/nodes/helper.js');
|
|
||||||
|
|
||||||
describe('exif node', function() {
|
describe('exif node', function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -35,17 +33,16 @@ describe('exif node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('extracts location data from Exif data of JPEG', function(done) {
|
it('extracts location data from Exif data of JPEG', function(done) {
|
||||||
|
|
||||||
var exif = require('exif');
|
var exif = require('exif');
|
||||||
var ExifImage = exif.ExifImage;
|
var ExifImage = exif.ExifImage;
|
||||||
|
|
||||||
// the jpg file is a single black dot but it was originally a photo taken at IBM Hursley
|
// 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;
|
var eD;
|
||||||
|
|
||||||
new ExifImage({ image : data }, function (error, exifData) {
|
new ExifImage({ image : data }, function (error, exifData) {
|
||||||
if(error) {
|
if (error) {
|
||||||
done(error);
|
done(error);
|
||||||
} else {
|
} else {
|
||||||
eD = exifData;
|
eD = exifData;
|
||||||
|
Loading…
Reference in New Issue
Block a user