Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 0a12b5c

Browse files
committed
test: add tests for pathToArray
1 parent 83e1ffc commit 0a12b5c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/MemoryFileSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ MemoryFileSystem.prototype.writeFileSync = function(_path, content, encoding) {
214214
};
215215

216216
MemoryFileSystem.prototype.join = require("./join");
217-
217+
MemoryFileSystem.prototype.pathToArray = pathToArray;
218218
MemoryFileSystem.prototype.normalize = normalize;
219219

220220
// stream functions

test/MemoryFileSystem.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ describe("normalize", function() {
335335
fs.normalize("C:\\a\\b\\d\\\\.\\\\.\\c\\.\\..").should.be.eql("C:\\a\\b\\d");
336336
});
337337
});
338+
describe("pathToArray", function() {
339+
it("should split path to an array of parts", function() {
340+
var fs = new MemoryFileSystem();
341+
fs.pathToArray("/a/b/c").should.be.eql(["a", "b", "c"]);
342+
fs.pathToArray("C:/a/b").should.be.eql(["C:", "a", "b"]);
343+
fs.pathToArray("C:\\a\\b").should.be.eql(["C:", "a", "b"]);
344+
});
345+
it("should fail on invalid paths", function() {
346+
(function() {
347+
fs.pathToArray("0:/");
348+
}).should.throw();
349+
});
350+
});
338351
describe("join", function() {
339352
it("should join paths", function() {
340353
var fs = new MemoryFileSystem();

0 commit comments

Comments
 (0)