From 2db65b9d1f4faa101b951d67b7d3efee4e76ae23 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 6 Mar 2017 15:28:23 +0000 Subject: [PATCH] fixes for grunt files tests on Windows --- .../runtime/nodes/registry/installer_spec.js | 10 ++++-- test/red/runtime/storage/index_spec.js | 35 ++++++++++--------- .../runtime/storage/localfilesystem_spec.js | 7 ++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/test/red/runtime/nodes/registry/installer_spec.js b/test/red/runtime/nodes/registry/installer_spec.js index 21a59e1d2..7c9b835a5 100644 --- a/test/red/runtime/nodes/registry/installer_spec.js +++ b/test/red/runtime/nodes/registry/installer_spec.js @@ -128,8 +128,14 @@ describe('nodes/registry/installer', function() { installer.installModule(resourcesDir).then(function() { done(new Error("Unexpected success")); }).otherwise(function(err) { - err.code.should.eql(404); - done(); + if (err.hasOwnProperty("code")) { + err.code.should.eql(404); + done(); + } + else { + err.message.should.eql("Install failed"); + done(); + } }); }); it("succeeds when path is valid node-red module", function(done) { diff --git a/test/red/runtime/storage/index_spec.js b/test/red/runtime/storage/index_spec.js index c97652168..428b1d1d6 100644 --- a/test/red/runtime/storage/index_spec.js +++ b/test/red/runtime/storage/index_spec.js @@ -15,6 +15,7 @@ **/ var when = require("when"); var should = require("should"); +var paff = require('path'); var storage = require("../../../../red/runtime/storage/index"); describe("red/storage/index", function() { @@ -27,17 +28,17 @@ describe("red/storage/index", function() { } }; - storage.init(wrongModule).then( function() { - var one = 1; - var zero = 0; - try { - zero.should.equal(one, "The initialization promise should never get resolved"); - } catch(err) { - done(err); - } - }).catch(function(e) { - done(); //successfully rejected promise - }); + storage.init(wrongModule).then( function() { + var one = 1; + var zero = 0; + try { + zero.should.equal(one, "The initialization promise should never get resolved"); + } catch(err) { + done(err); + } + }).catch(function(e) { + done(); //successfully rejected promise + }); }); it('non-string storage module', function(done) { @@ -169,11 +170,11 @@ describe("red/storage/index", function() { }, getLibraryEntry : function(type, path) { if (type === "flows") { - if (path == "/") { + if (path === "/" || path === "\\") { return when.resolve(["a",{fn:"test.json"}]); - } else if (path == "/a") { + } else if (path == "/a" || path == "\\a") { return when.resolve([{fn:"test2.json"}]); - } else if (path == "/a/test2.json") { + } else if (path == paff.join("","a","test2.json")) { return when.resolve("test content"); } } @@ -207,7 +208,7 @@ describe("red/storage/index", function() { }); it('getFlow',function(done) { - storage.getFlow("/a/test2.json").then(function(res) { + storage.getFlow(paff.join("a","test2.json")).then(function(res) { try { res.should.eql("test content"); done(); @@ -218,9 +219,9 @@ describe("red/storage/index", function() { }); it ('saveFlow', function (done) { - storage.saveFlow("/a/test2.json","new content").then(function(res) { + storage.saveFlow(paff.join("a","test2.json"),"new content").then(function(res) { try { - savePath.should.eql("/a/test2.json"); + savePath.should.eql(paff.join("a","test2.json")); saveContent.should.eql("new content"); saveMeta.should.eql({}); saveType.should.eql("flows"); diff --git a/test/red/runtime/storage/localfilesystem_spec.js b/test/red/runtime/storage/localfilesystem_spec.js index f3fcbfd44..4251fcb62 100644 --- a/test/red/runtime/storage/localfilesystem_spec.js +++ b/test/red/runtime/storage/localfilesystem_spec.js @@ -587,10 +587,11 @@ describe('LocalFileSystem', function() { createObjectLibrary(); localfilesystem.getLibraryEntry('object','B').then(function(flows) { flows.should.eql([ 'C', { ghi: 'jkl', fn: 'file2.js' }, {fn:'flow.json'} ]); - localfilesystem.saveLibraryEntry('object','B/D/file3.js',{mno:'pqr'},"// another non meta line\n\n Hi There").then(function() { - localfilesystem.getLibraryEntry('object','B/D').then(function(flows) { + var ft = path.join("B","D","file3.js"); + localfilesystem.saveLibraryEntry('object',ft,{mno:'pqr'},"// another non meta line\n\n Hi There").then(function() { + localfilesystem.getLibraryEntry('object',path.join("B","D")).then(function(flows) { flows.should.eql([ { mno: 'pqr', fn: 'file3.js' } ]); - localfilesystem.getLibraryEntry('object','B/D/file3.js').then(function(body) { + localfilesystem.getLibraryEntry('object',ft).then(function(body) { body.should.eql("// another non meta line\n\n Hi There"); done(); }).otherwise(function(err) {