Skip to content

Commit b11f181

Browse files
Copilotpelikhan
andcommitted
Add comprehensive test coverage for workspace and git integration
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent a0ae7ae commit b11f181

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

packages/core/test/exports.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, test, expect } from "vitest";
2+
3+
describe("exports verification", () => {
4+
test("can import new workspace functions from core", async () => {
5+
const { createWorkspace, createWorkspaceFileSystem, WorkspaceContext } = await import("../src/workspace.js");
6+
7+
expect(createWorkspace).toBeDefined();
8+
expect(typeof createWorkspace).toBe("function");
9+
10+
expect(createWorkspaceFileSystem).toBeDefined();
11+
expect(typeof createWorkspaceFileSystem).toBe("function");
12+
13+
// Test they work together
14+
const { filesystem, git } = createWorkspace();
15+
expect(filesystem).toBeDefined();
16+
expect(git).toBeDefined();
17+
expect(git.workspace).toBe(filesystem);
18+
});
19+
20+
test("can import from index", async () => {
21+
const { createWorkspace, createWorkspaceFileSystem, GitClient } = await import("../src/index.js");
22+
23+
expect(createWorkspace).toBeDefined();
24+
expect(createWorkspaceFileSystem).toBeDefined();
25+
expect(GitClient).toBeDefined();
26+
27+
// Test integration
28+
const { filesystem, git } = createWorkspace();
29+
expect(git).toBeInstanceOf(GitClient);
30+
expect(git.workspace).toBe(filesystem);
31+
});
32+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { describe, test, expect } from "vitest";
2+
import { GitClient } from "../src/git.js";
3+
4+
describe("GitClient backward compatibility", () => {
5+
test("default GitClient singleton still works", () => {
6+
const git = GitClient.default();
7+
expect(git).toBeDefined();
8+
expect(typeof git.cwd).toBe("string");
9+
expect(git.workspace).toBeUndefined(); // Default should not have workspace
10+
});
11+
12+
test("GitClient constructor with only cwd still works", () => {
13+
const git = new GitClient("/some/path");
14+
expect(git.cwd).toBe("/some/path");
15+
expect(git.workspace).toBeUndefined();
16+
});
17+
18+
test("GitClient.client() with only cwd still works", () => {
19+
const git = GitClient.default();
20+
const newGit = git.client("/another/path");
21+
expect(newGit.cwd).toBe("/another/path");
22+
expect(newGit.workspace).toBeUndefined();
23+
});
24+
25+
test("all existing GitClient methods are available", () => {
26+
const git = new GitClient("/test");
27+
28+
// Check key methods exist
29+
expect(typeof git.defaultBranch).toBe("function");
30+
expect(typeof git.branch).toBe("function");
31+
expect(typeof git.exec).toBe("function");
32+
expect(typeof git.fetch).toBe("function");
33+
expect(typeof git.pull).toBe("function");
34+
expect(typeof git.listBranches).toBe("function");
35+
expect(typeof git.listFiles).toBe("function");
36+
expect(typeof git.diff).toBe("function");
37+
expect(typeof git.log).toBe("function");
38+
expect(typeof git.client).toBe("function");
39+
expect(typeof git.toString).toBe("function");
40+
});
41+
});

0 commit comments

Comments
 (0)