deno.land / x / wasm@wasmer-sdk-v0.6.0 / tests / directory.test.ts

directory.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { expect } from "@esm-bundle/chai";import { init, initializeLogger, Directory } from "..";
const decoder = new TextDecoder("utf-8");const encoder = new TextEncoder();
const initialized = (async () => { await init(new URL("../dist/wasmer_js_bg.wasm", import.meta.url)); initializeLogger("warn");})();
describe("In-Memory Directory", function () { this.beforeAll(async () => await initialized);
it("read empty dir", async () => { const dir = new Directory();
const contents = await dir.readDir("/");
expect(contents.length).to.equal(0); });
it("can round-trip a file", async () => { const dir = new Directory();
await dir.writeFile("/file.txt", encoder.encode("Hello, World!")); const contents = await dir.readFile("/file.txt");
expect(decoder.decode(contents)).to.equal("Hello, World!"); });
it("read dir with file", async () => { const dir = new Directory();
await dir.writeFile("/file.txt", new Uint8Array()); const contents = await dir.readDir("/");
expect(contents).to.deep.equal([{ name: "file.txt", type: "file" }]); });
it("create child dir", async () => { const dir = new Directory();
await dir.createDir("/tmp/");
expect(await dir.readDir("/")).to.deep.equal([ { name: "tmp", type: "dir" }, ]); });
it("can be created with DirectoryInit", async () => { const dir = new Directory({ "/file.txt": "file", "/another/nested/file.txt": "another", });
expect(await dir.readTextFile("/file.txt")).to.equal("file"); expect(await dir.readTextFile("/another/nested/file.txt")).to.equal( "another", ); });});
wasm

Version Info

Tagged at
4 months ago