Skip to content

Commit

Permalink
test for zipnamefix
Browse files Browse the repository at this point in the history
  • Loading branch information
5saviahv committed Jun 24, 2024
1 parent 3c7f4a9 commit 1eecf55
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
const { expect } = require("chai");
const { crc32, canonical, sanitize } = require("../util/utils");
const { crc32, canonical, sanitize, zipnamefix } = require("../util/utils");
const pth = require("path");

describe("utils", () => {
Expand Down Expand Up @@ -70,6 +70,31 @@ describe("utils", () => {
});

it("function canonical()", () => {
const tests = [
// no name
{ file: "", result: "" },
// file has name
{ file: "file", result: "file" },
{ file: "../file", result: "file" },
{ file: "../../../file", result: "file" },
{ file: "./../file", result: "file" },
{ file: "../../file", result: "file" },
{ file: "../../file1/../file2", result: "file2" },
{ file: "../subfolder/file2", result: pth.normalize("subfolder/file2") },
{ file: "../subfolder2/file2", result: pth.normalize("subfolder2/file2") },
{ file: "../subfolder/file2", result: pth.normalize("subfolder/file2") },
{ file: "../../subfolder2/file2", result: pth.normalize("subfolder2/file2") }
];

for (const { file, result } of Array.from(tests)) {
tests.push({ result, file: file.split("/").join("\\") });
}

for (let test of tests) {
expect(canonical(test.file)).to.equal(test.result);
}
});
it("function zipnamefix()", () => {
const tests = [
// no name
{ file: "", result: "" },
Expand All @@ -91,7 +116,7 @@ describe("utils", () => {
}

for (let test of tests) {
expect(canonical(test.file)).to.equal(test.result);
expect(zipnamefix(test.file)).to.equal(test.result);
}
});
});
Expand Down

0 comments on commit 1eecf55

Please sign in to comment.