mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 16:31:04 -05:00
Fixed tests
This commit is contained in:
parent
1daa7e09c2
commit
714640b5e5
1 changed files with 11 additions and 7 deletions
|
@ -1,22 +1,26 @@
|
||||||
import { describe, test, expect } from "@jest/globals";
|
import { describe, test, expect, beforeAll, afterAll } from "@jest/globals";
|
||||||
import { computeHash } from "../src/utils/hash-utils";
|
import { computeHash } from "../src/utils/hash-utils";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
describe("computeHash", () => {
|
describe("computeHash", () => {
|
||||||
|
beforeAll(() => new Promise(resolve => {
|
||||||
|
fs.writeFile("hello-world.txt", "Hello world!", resolve);
|
||||||
|
}));
|
||||||
|
|
||||||
|
afterAll(() => new Promise(resolve => fs.unlink("hello-world.txt", resolve)));
|
||||||
|
|
||||||
test("sha1 is supported", async () => {
|
test("sha1 is supported", async () => {
|
||||||
const algorithm = "sha1";
|
const algorithm = "sha1";
|
||||||
expect((await computeHash("./test/content/fabric.mod.json", algorithm)).digest("hex")).toBe("be90f16aa5c806e2bbcf151efee4ebce7899256b");
|
expect((await computeHash("hello-world.txt", algorithm)).digest("hex")).toBe("d3486ae9136e7856bc42212385ea797094475802");
|
||||||
expect((await computeHash("./test/content/mods.toml", algorithm)).digest("hex")).toBe("bf13f9ca36d5a5ebd55a3bda0b432ab4a007791a");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sha256 is supported", async () => {
|
test("sha256 is supported", async () => {
|
||||||
const algorithm = "sha256";
|
const algorithm = "sha256";
|
||||||
expect((await computeHash("./test/content/fabric.mod.json", algorithm)).digest("hex")).toBe("583334cd90510cdc5c5068dd7cc3423adc9674abf8e200b3a165216bb0f6346d");
|
expect((await computeHash("hello-world.txt", algorithm)).digest("hex")).toBe("c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a");
|
||||||
expect((await computeHash("./test/content/mods.toml", algorithm)).digest("hex")).toBe("c420fd754f32553dde2a5118c27ca83b644ba73d230baf723fa00d5cb5b1aaac");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sha512 is supported", async () => {
|
test("sha512 is supported", async () => {
|
||||||
const algorithm = "sha512";
|
const algorithm = "sha512";
|
||||||
expect((await computeHash("./test/content/fabric.mod.json", algorithm)).digest("hex")).toBe("18582ba1fbec5ab05d5b5679f6d5fa157792959fd22ac091f1be264fc709996d900c8514265f0d24e533c1174da2919fdd7441d1215bbf6866e68f71114979af");
|
expect((await computeHash("hello-world.txt", algorithm)).digest("hex")).toBe("f6cde2a0f819314cdde55fc227d8d7dae3d28cc556222a0a8ad66d91ccad4aad6094f517a2182360c9aacf6a3dc323162cb6fd8cdffedb0fe038f55e85ffb5b6");
|
||||||
expect((await computeHash("./test/content/mods.toml", algorithm)).digest("hex")).toBe("b15c84290a1f9fad17fa4f3429fbb67d2555feafd617a5399ba95d5b6745659bc50e16e810d3bfe5bbdd4b66720b85daafd5ad78ece9a484c356c358d7b295ec");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue