forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchanges.test.ts
More file actions
57 lines (47 loc) · 1.49 KB
/
Copy pathchanges.test.ts
File metadata and controls
57 lines (47 loc) · 1.49 KB
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
import { describe, expect, it, vi } from "vitest";
import { getChangesSummary, getLastReleaseTag } from "./changes.js";
const spawnSyncMock = vi.hoisted(() => vi.fn());
vi.mock("child_process", () => ({
spawnSync: spawnSyncMock,
}));
function mockGitHistory(): void {
spawnSyncMock.mockImplementation((command: string, args: string[]) => {
if (command !== "git") throw new Error(`unexpected command: ${command}`);
if (args[0] === "tag") {
return { stdout: "v1.62.3\nchannels/v0.1.1\n" };
}
if (args[0] === "log") {
return { stdout: "abc1234 feat(channels): shared release\n" };
}
throw new Error(`unexpected git arguments: ${args.join(" ")}`);
});
}
describe("Channels release history", () => {
it("selects the Channels tag instead of the monorepo tag", () => {
mockGitHistory();
expect(getLastReleaseTag("channels")).toBe("channels/v0.1.1");
expect(spawnSyncMock).toHaveBeenCalledWith(
"git",
["tag", "--list", "channels/v*", "--sort=-v:refname"],
expect.any(Object),
);
});
it("uses the Channels tag as the release-note commit boundary", () => {
mockGitHistory();
expect(getChangesSummary("channels")).toMatchObject({
lastTag: "channels/v0.1.1",
commitCount: 1,
});
expect(spawnSyncMock).toHaveBeenLastCalledWith(
"git",
[
"log",
"channels/v0.1.1..HEAD",
"--oneline",
"--no-merges",
"--format=%H %s",
],
expect.any(Object),
);
});
});