mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
add a few tests
geohash, smooth, base64, msgpack
This commit is contained in:
@@ -50,7 +50,21 @@ describe('geohash node', function() {
|
||||
msg.should.have.a.property("payload", "gcnfju78x");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {payload:"51.0,-1.5"});
|
||||
n1.emit("input", {payload:"51.0,-1.5,10"});
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert payload lat,lon to geohash at low precision', function(done) {
|
||||
var flow = [{"id":"n1", "type":"geohash", func:"geohash", gap:0, wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
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", "g");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {payload:"51.0,-1.5,0"});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,7 +107,22 @@ describe('geohash node', function() {
|
||||
msg.payload.should.have.a.property("geohash", "t9cbbukqn");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {payload:{latitude:10,longitude:70}});
|
||||
n1.emit("input", {payload:{latitude:10,longitude:70,precision:10}});
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert payload object lat,lon to geohash (low precision)', function(done) {
|
||||
var flow = [{"id":"n1", "type":"geohash", func:"geohash", gap:0, wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
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.have.a.property("geohash", "t");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {payload:{latitude:10,longitude:70,precision:-1}});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -125,7 +154,22 @@ describe('geohash node', function() {
|
||||
msg.location.should.have.a.property("geohash", "kukqnpp5e");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {location:{lat:-20,lon:40}});
|
||||
n1.emit("input", {location:{lat:-20,lon:40,precision:10}});
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert location lat, lon to geohash (low precision)', function(done) {
|
||||
var flow = [{"id":"n1", "type":"geohash", func:"geohash", gap:0, wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
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("location");
|
||||
msg.location.should.have.a.property("geohash", "k");
|
||||
done();
|
||||
});
|
||||
n1.emit("input", {location:{lat:-20,lon:40,precision:-1}});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -227,7 +271,7 @@ describe('geohash node', function() {
|
||||
msg.should.have.property('msg', 'Unexpected string format - should be lat,lon');
|
||||
done();
|
||||
},50);
|
||||
n1.emit("input", {payload:"bananas,apples,pears"});
|
||||
n1.emit("input", {payload:"bananas,apples,pears,oranges"});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user