-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
33 lines (29 loc) · 1003 Bytes
/
index.test.js
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
import { describe, it, expect } from "vitest";
import fsx from "fs-extra";
import {
generateKey,
encryptAndZipFolder,
unzipAndDecryptZip,
} from "./index.js";
await fsx.remove("tmp");
await fsx.ensureDir("tmp");
describe("monozip", () => {
const cryptkey = generateKey();
const fixtureFolderPath = "./fixtures/medias";
const zipPath = "tmp/medias.zip";
it("should encrypt & zip", async () => {
await encryptAndZipFolder(cryptkey, fixtureFolderPath, {
outputPath: zipPath,
});
expect(await fsx.pathExists(zipPath)).toBe(true);
});
it("should unzip & decrypt", async () => {
await unzipAndDecryptZip(cryptkey, zipPath);
expect(await fsx.pathExists("tmp/medias-decrypted")).toBe(true);
expect(await fsx.pathExists("tmp/medias-decrypted/seoul.mp4")).toBe(true);
expect(await fsx.pathExists("tmp/medias-decrypted/hello.txt")).toBe(true);
expect(
await fsx.readFile("tmp/medias-decrypted/hello.txt", "utf-8")
).toEqual("hello");
});
});