diff --git a/lib/fileOps.spec.js b/lib/fileOps.spec.js index b9eda49c..ed89f469 100644 --- a/lib/fileOps.spec.js +++ b/lib/fileOps.spec.js @@ -100,7 +100,8 @@ describe("fileOps.js", function(){ fs.statSync("lib/test"); }, Error); assert(x); - }); + // give it some extra time because its sometimes very slow + }).timeout(5000); it("returns false if you give it an invalid path", function(){ let x = fileOps.deleteFolderRecursiveSync("This isn't a real path"); assert(!x); diff --git a/lib/objectOps.js b/lib/objectOps.js index 3bf9e988..e5d4d716 100644 --- a/lib/objectOps.js +++ b/lib/objectOps.js @@ -1,48 +1,7 @@ -var copyChildren = function(d){ - var copied = clone(d); - copy = []; - if(copied.children){ - copied.children.forEach(function(h){ - copy.push(h); - }); - } - if(copied._children){ - copied._children.forEach(function(h){ - copy.push(h); - }); - } -} - -var clone = function(obj) { - if (null == obj || "object" != typeof obj) return obj; - var copy = obj.constructor(); - for (var attr in obj) { - if (obj.hasOwnProperty(attr) && attr != "parent"){ - if(attr == "children" && obj[attr] != null){ - copy[attr] = obj[attr].map(function (d) { - var subCopy = clone(d); - return subCopy; - }); - } - else if(attr == "_children" && obj[attr] != null){ - copy[attr] = obj[attr].map(function(d) { - var subCopy = clone(d); - return subCopy; - }); - } - else{ - copy[attr] = obj[attr]; - } - } - } - return copy; -} - var deepclone = function(obj){ return JSON.parse(JSON.stringify(obj)); } module.exports = { - clone:clone, deepclone:deepclone, }; \ No newline at end of file diff --git a/lib/objectOps.spec.js b/lib/objectOps.spec.js index 2e16ee64..c10a00a9 100644 --- a/lib/objectOps.spec.js +++ b/lib/objectOps.spec.js @@ -2,7 +2,7 @@ var assert = require('assert'); var objectOps = require('./objectOps'); describe("objectOps.js", function(){ - describe("objectOps.clone()", function(){ + /*describe("objectOps.clone()", function(){ it("clones javascript objects", function(){ var object1 = {hello:"world", cat:{legs:4, name:"Kitty", colors:["brown", "yellow", "purple"]}}; var object2 = {}; @@ -20,7 +20,7 @@ describe("objectOps.js", function(){ assert.equal(obj1.cat.colors, "black"); assert.notEqual(obj2.cat.colors[1], "yellow"); }); - }); + });*/ describe("objectOps.deepclone()", function(){ it("deep clones javascript objects", function(){ var obj1 = {hello:"world", cat:{legs:4, name:"Kitty", colors:["brown", "yellow", "purple"]}}; @@ -32,9 +32,8 @@ describe("objectOps.js", function(){ assert.equal(obj2.cat.colors[1], "yellow"); }); it("throws on non JSON parameters", function(){ - x = function(){}; assert.throws(function(){ - y = objectOps.deepclone(x) + let y = objectOps.deepclone(objectOps.deepclone); }); }); }); diff --git a/sharedPlugins/inventoryImports/interfacingFunctions.spec.js b/sharedPlugins/inventoryImports/interfacingFunctions.spec.js index 90411831..d7b84808 100644 --- a/sharedPlugins/inventoryImports/interfacingFunctions.spec.js +++ b/sharedPlugins/inventoryImports/interfacingFunctions.spec.js @@ -44,7 +44,7 @@ describe("inventoryImports/interfacingFunctions.js", function(){ if(body.name == "iron-plate") assert(body.count == "92"); // nock wants us to return true if this is the correct body and we should reply // if we return false we won't send a reply. - return x + return true; }) // nock destroys the endpoints after being hit once, this changes the number of hits required for destruction .times(10)