-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathreadDescription.test.ts
45 lines (34 loc) · 1.07 KB
/
readDescription.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
import { describe, expect, it, vi } from "vitest";
import { readDescription } from "./readDescription.js";
const mockSourcePackageJsonDescription = vi.fn<() => string>();
vi.mock("./blocks/sourcePackageJson", () => ({
sourcePackageJson: {
get description() {
return mockSourcePackageJsonDescription();
},
},
}));
describe("finalize", () => {
it("returns undefined when the description matches the current package.json description", async () => {
const existing = "Same description.";
mockSourcePackageJsonDescription.mockReturnValueOnce(existing);
const documentation = await readDescription(() =>
Promise.resolve({
description: existing,
}),
);
expect(documentation).toBeUndefined();
});
it("filters known headings when .github/DEVELOPMENT.md exists", async () => {
const updated = "Updated description.";
mockSourcePackageJsonDescription.mockReturnValueOnce(
"Existing description",
);
const documentation = await readDescription(() =>
Promise.resolve({
description: updated,
}),
);
expect(documentation).toBe(updated);
});
});