forked from photopea/UZIP.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.ts
32 lines (28 loc) · 941 Bytes
/
mod.test.ts
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
import { decode, encode } from "./mod.ts";
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
Deno.test("zip and unzip", async (t) => {
await t.step("text files", async () => {
const obj = {
"file1.txt": new Uint8Array([72, 69, 76, 76, 79]),
"file2.txt": new Uint8Array([72, 69, 76, 76, 79]),
};
for await (const entry of decode(await encode(obj))) {
assertEquals(
new Uint8Array(await entry.arrayBuffer()),
obj[entry.name as keyof typeof obj],
);
}
});
await t.step("UTF-8 filename", async () => {
const obj = {
"ファイル.txt": new Uint8Array([72, 69, 76, 76, 79]),
"✅☺👍.txt": new Uint8Array([72, 69, 76, 76, 79]),
};
for await (const entry of decode(await encode(obj))) {
assertEquals(
new Uint8Array(await entry.arrayBuffer()),
obj[entry.name as keyof typeof obj],
);
}
});
});