2026-01-17 06:26:27 +00:00
|
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
|
|
const watchMock = vi.fn(() => ({
|
|
|
|
|
on: vi.fn(),
|
|
|
|
|
close: vi.fn(async () => undefined),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.mock("chokidar", () => {
|
|
|
|
|
return {
|
|
|
|
|
default: { watch: watchMock },
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("ensureSkillsWatcher", () => {
|
2026-01-17 08:04:24 +00:00
|
|
|
it("ignores node_modules, dist, and .git by default", async () => {
|
2026-01-17 06:26:27 +00:00
|
|
|
const mod = await import("./refresh.js");
|
|
|
|
|
mod.ensureSkillsWatcher({ workspaceDir: "/tmp/workspace" });
|
|
|
|
|
|
|
|
|
|
expect(watchMock).toHaveBeenCalledTimes(1);
|
|
|
|
|
const opts = watchMock.mock.calls[0]?.[1] as { ignored?: unknown };
|
|
|
|
|
|
2026-01-17 08:04:24 +00:00
|
|
|
expect(opts.ignored).toBe(mod.DEFAULT_SKILLS_WATCH_IGNORED);
|
|
|
|
|
const ignored = mod.DEFAULT_SKILLS_WATCH_IGNORED;
|
2026-01-17 06:26:27 +00:00
|
|
|
expect(ignored.some((re) => re.test("/tmp/workspace/skills/node_modules/pkg/index.js"))).toBe(
|
|
|
|
|
true,
|
|
|
|
|
);
|
2026-01-31 18:31:49 +09:00
|
|
|
expect(ignored.some((re) => re.test("/tmp/workspace/skills/dist/index.js"))).toBe(true);
|
2026-01-17 06:26:27 +00:00
|
|
|
expect(ignored.some((re) => re.test("/tmp/workspace/skills/.git/config"))).toBe(true);
|
2026-01-17 08:04:24 +00:00
|
|
|
expect(ignored.some((re) => re.test("/tmp/.hidden/skills/index.md"))).toBe(false);
|
2026-01-17 06:26:27 +00:00
|
|
|
});
|
|
|
|
|
});
|