forked from Voxelum/minecraft-launcher-core-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.test.ts
More file actions
41 lines (39 loc) · 1.61 KB
/
utils.test.ts
File metadata and controls
41 lines (39 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { join, normalize } from "path";
import { checksum, validateSha1 } from "./utils";
const root = normalize(join(__dirname, "..", "..", "mock"));
describe("util", () => {
describe("#validateSha1", () => {
test("should return false if the file not found", async () => {
await expect(validateSha1(join(root, "test.ss")))
.resolves
.toEqual(false);
});
test("should return false if the sha not matched", async () => {
await expect(validateSha1(join(root, "options.txt"), "abc"))
.resolves
.toEqual(false);
});
test("should return true if the sha matched", async () => {
await expect(validateSha1(join(root, "options.txt"), "e1719c99026ae3714ea24f13f50cdf6894844511"))
.resolves
.toEqual(true);
});
test("should return true if the sha not given and file existed in non strict", async () => {
await expect(validateSha1(join(root, "options.txt")))
.resolves
.toEqual(true);
});
test("should return false if the sha not given and file existed in strict", async () => {
await expect(validateSha1(join(root, "options.txt"), undefined, true))
.resolves
.toEqual(false);
});
});
describe("#checksum", () => {
test("should get sha1", async () => {
await expect(checksum(join(root, "options.txt"), "sha1"))
.resolves
.toEqual("e1719c99026ae3714ea24f13f50cdf6894844511");
});
});
});