aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2018-01-26 23:21:49 +0000
committerMichael Williamson <mike@zwobble.org>2018-01-26 23:21:49 +0000
commit9196e8bc6f2ff2c59a9b4fde4813e7bc26b8c23d (patch)
treec42bfa3fb88f2348018c63f7dc1a64299a666355 /test
parentf5fbc6e4aface5c6c9537b38d1650b0d37e3cbc1 (diff)
Extract joinPath and splitPath for zip files
Diffstat (limited to 'test')
-rw-r--r--test/zipfile.tests.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/zipfile.tests.js b/test/zipfile.tests.js
index 56c7f9b..3087dc8 100644
--- a/test/zipfile.tests.js
+++ b/test/zipfile.tests.js
@@ -22,3 +22,29 @@ function emptyZipFile() {
var buffer = zip.generate({type: "arraybuffer"});
return zipfile.openArrayBuffer(buffer);
}
+
+
+test("splitPath splits zip paths on last forward slash", function() {
+ assert.deepEqual(zipfile.splitPath("a/b"), {dirname: "a", basename: "b"});
+ assert.deepEqual(zipfile.splitPath("a/b/c"), {dirname: "a/b", basename: "c"});
+ assert.deepEqual(zipfile.splitPath("/a/b/c"), {dirname: "/a/b", basename: "c"});
+});
+
+
+test("when path has no forward slashes then splitPath returns empty dirname", function() {
+ assert.deepEqual(zipfile.splitPath("name"), {dirname: "", basename: "name"});
+});
+
+
+test("joinPath joins arguments with forward slashes", function() {
+ assert.equal(zipfile.joinPath("a", "b"), "a/b");
+ assert.equal(zipfile.joinPath("a/b", "c"), "a/b/c");
+ assert.equal(zipfile.joinPath("/a/b", "c"), "/a/b/c");
+});
+
+
+test("empty parts are ignored when joining paths", function() {
+ assert.equal(zipfile.joinPath("a", ""), "a");
+ assert.equal(zipfile.joinPath("", "b"), "b");
+ assert.equal(zipfile.joinPath("a", "", "b"), "a/b");
+});