Skip to content

Commit

Permalink
test: add tests for pathToArray
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Sep 7, 2016
1 parent 83e1ffc commit 0a12b5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/MemoryFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/MemoryFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0a12b5c

Please sign in to comment.