-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathfs.test.ts
More file actions
38 lines (33 loc) · 958 Bytes
/
Copy pathfs.test.ts
File metadata and controls
38 lines (33 loc) · 958 Bytes
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
import { createFixture } from "fs-fixture";
import { describe, expect, it } from "vitest";
import { normalizeFileChanges } from "../src/fs.ts";
describe("normalizeFileChanges", () => {
it("should convert file contents to base64", async () => {
await using fixture = await createFixture({
"foo.txt": "Hello, world!",
});
const result = await normalizeFileChanges(
{
additions: ["foo.txt"],
deletions: ["bar.txt"],
},
fixture.path,
);
expect(result).toEqual({
additions: [
{
path: "foo.txt",
contents: await fixture.readFile("foo.txt", "base64"),
},
],
deletions: [{ path: "bar.txt" }],
});
});
it("should pass through empty file changes", async () => {
const result = await normalizeFileChanges(
{ additions: [], deletions: [] },
"/",
);
expect(result).toEqual({ additions: [], deletions: [] });
});
});