fixup node-red-nodes grunt test

This commit is contained in:
Dave Conway-Jones 2024-06-30 17:19:46 +01:00
parent dba4451f57
commit 35c4061748
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
4 changed files with 13 additions and 11 deletions

View File

@ -17,7 +17,7 @@ module.exports = function(grunt) {
}, },
jshint: { jshint: {
options: { options: {
jshintrc:true // Use external jshinrc file configured as below jshintrc:true // Use external jshintrc file configured as below
// http://www.jshint.com/docs/options/ // http://www.jshint.com/docs/options/
//"asi": true, // allow missing semicolons //"asi": true, // allow missing semicolons
//"curly": true, // require braces //"curly": true, // require braces

View File

@ -35,7 +35,7 @@
"feedparser": "^2.2.10", "feedparser": "^2.2.10",
"grunt": "^1.6.1", "grunt": "^1.6.1",
"grunt-cli": "^1.4.3", "grunt-cli": "^1.4.3",
"grunt-contrib-jshint": "^2.1.0", "grunt-contrib-jshint": "^3.2.0",
"grunt-jscs": "^3.0.1", "grunt-jscs": "^3.0.1",
"grunt-lint-inline": "^1.0.0", "grunt-lint-inline": "^1.0.0",
"grunt-simple-mocha": "^0.4.1", "grunt-simple-mocha": "^0.4.1",
@ -46,7 +46,7 @@
"msgpack-lite": "^0.1.26", "msgpack-lite": "^0.1.26",
"multilang-sentiment": "^1.2.0", "multilang-sentiment": "^1.2.0",
"ngeohash": "^0.6.3", "ngeohash": "^0.6.3",
"node-red": "^3.1.0", "node-red": "^4.0.1",
"node-red-node-test-helper": "^0.3.2", "node-red-node-test-helper": "^0.3.2",
"nodemailer": "^6.9.7", "nodemailer": "^6.9.7",
"node-pop3": "^0.9.0", "node-pop3": "^0.9.0",

View File

@ -53,8 +53,8 @@ describe('exif node', function() {
helperNode1.on("input", function(msg) { helperNode1.on("input", function(msg) {
// exif.ExifImage.restore(); // exif.ExifImage.restore();
msg.location.lat.should.equal(51.04365); // this data is stored in the jpg file msg.location.lat.should.equal(51.04364722222222); // this data is stored in the jpg file
msg.location.lon.should.equal(-1.31525); msg.location.lon.should.equal(-1.3152472222222222);
done(); done();
}); });
@ -117,9 +117,9 @@ describe('exif node', function() {
var logEvents = helper.log().args.filter(function(evt) { var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == "exif"; return evt[0].type == "exif";
}); });
logEvents.should.have.length(1); logEvents.should.have.length(2);
logEvents[0][0].should.have.a.property('msg'); logEvents[1][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Error: The given image is not a JPEG"); logEvents[1][0].msg.toString().should.startWith("Error: Invalid image format");
done(); done();
},150); },150);

View File

@ -90,9 +90,11 @@ module.exports = function(RED) {
if (Buffer.isBuffer(value)) { // or a proper jpg buffer if (Buffer.isBuffer(value)) { // or a proper jpg buffer
msg.exif = ExifReader.load(msg.payload); msg.exif = ExifReader.load(msg.payload);
for (const p in msg.exif) { for (const p in msg.exif) {
msg.exif[p] = msg.exif[p].description if (msg.exif.hasOwnProperty(p)) {
if (!isNaN(Number(msg.exif[p]))) { msg.exif[p] = msg.exif[p].description
msg.exif[p] = Number(msg.exif[p]) if (!isNaN(Number(msg.exif[p]))) {
msg.exif[p] = Number(msg.exif[p])
}
} }
} }
if (msg.exif && msg.exif.hasOwnProperty("GPSLatitude") && msg.exif.hasOwnProperty("GPSLongitude")) { if (msg.exif && msg.exif.hasOwnProperty("GPSLatitude") && msg.exif.hasOwnProperty("GPSLongitude")) {