diff --git a/lib/MemoryFileSystem.js b/lib/MemoryFileSystem.js index 99ef4af..abfe803 100644 --- a/lib/MemoryFileSystem.js +++ b/lib/MemoryFileSystem.js @@ -214,7 +214,7 @@ MemoryFileSystem.prototype.writeFileSync = function(_path, content, encoding) { }; MemoryFileSystem.prototype.join = require("./join"); - +MemoryFileSystem.prototype.pathToArray = pathToArray; MemoryFileSystem.prototype.normalize = normalize; // stream functions diff --git a/test/MemoryFileSystem.js b/test/MemoryFileSystem.js index 440634e..d11d889 100644 --- a/test/MemoryFileSystem.js +++ b/test/MemoryFileSystem.js @@ -335,6 +335,19 @@ describe("normalize", function() { fs.normalize("C:\\a\\b\\d\\\\.\\\\.\\c\\.\\..").should.be.eql("C:\\a\\b\\d"); }); }); +describe("pathToArray", function() { + it("should split path to an array of parts", function() { + var fs = new MemoryFileSystem(); + fs.pathToArray("/a/b/c").should.be.eql(["a", "b", "c"]); + fs.pathToArray("C:/a/b").should.be.eql(["C:", "a", "b"]); + fs.pathToArray("C:\\a\\b").should.be.eql(["C:", "a", "b"]); + }); + it("should fail on invalid paths", function() { + (function() { + fs.pathToArray("0:/"); + }).should.throw(); + }); +}); describe("join", function() { it("should join paths", function() { var fs = new MemoryFileSystem();