-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathwriteStructure.test.ts
46 lines (37 loc) · 1.02 KB
/
writeStructure.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
import { describe, expect, it, vi } from "vitest";
import { Options } from "../../shared/types.js";
import { writeStructure } from "./writeStructure.js";
const mock$ = vi.fn();
vi.mock("execa", () => ({
get $() {
return mock$;
},
}));
vi.mock("./creation/index.js");
vi.mock("./writeStructureWorker.js");
const options = {
access: "public",
author: "TestAuthor",
base: "everything",
description: "Test description.",
directory: ".",
email: {
github: "[email protected]",
npm: "[email protected]",
},
keywords: ["abc", "def ghi", "jkl mno pqr"],
mode: "create",
owner: "TestOwner",
repository: "test-repository",
title: "Test Title",
} satisfies Options;
describe("writeStructure", () => {
it("resolves when chmod resolves", async () => {
mock$.mockResolvedValue(undefined);
await expect(writeStructure(options)).resolves.toBeUndefined();
});
it("resolves when chmod rejects", async () => {
mock$.mockRejectedValue(new Error("Oh no!"));
await expect(writeStructure(options)).resolves.toBeUndefined();
});
});