Skip to content

Commit ec27fa9

Browse files
authored
Merge pull request #53 from Open330/oac/1772690720042-96b333b728a73b7b
test: add test coverage for file-filters.ts
2 parents 1f0040f + a7ee67b commit ec27fa9

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "1.0",
3+
"runId": "e9c717f6-ebac-4f44-97b3-55ff1d9a41cf",
4+
"timestamp": "2026-03-05T06:07:46.285Z",
5+
"contributor": "jiun",
6+
"task": {
7+
"id": "96b333b728a73b7b",
8+
"title": "Add tests for file-filters.ts",
9+
"source": "test-gap",
10+
"complexity": "simple"
11+
},
12+
"execution": {
13+
"success": true,
14+
"tokensUsed": 285138,
15+
"duration": 77.428,
16+
"filesChanged": [
17+
"tests/core/file-filters.test.ts"
18+
]
19+
}
20+
}

‎tests/core/file-filters.test.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { describe, expect, it } from "vitest";
2+
3+
import { filterRealChanges, isRealFileChange } from "../../src/core/file-filters.js";
4+
5+
describe("isRealFileChange", () => {
6+
it("returns true for regular source files", () => {
7+
expect(isRealFileChange("src/index.ts")).toBe(true);
8+
expect(isRealFileChange("README.md")).toBe(true);
9+
expect(isRealFileChange("package.json")).toBe(true);
10+
});
11+
12+
it("returns false for .oac/ metadata files", () => {
13+
expect(isRealFileChange(".oac/config.json")).toBe(false);
14+
expect(isRealFileChange(".oac/tasks/task-1.json")).toBe(false);
15+
});
16+
17+
it("returns true for files containing .oac in a non-prefix position", () => {
18+
expect(isRealFileChange("src/.oac-utils.ts")).toBe(true);
19+
expect(isRealFileChange("docs/oac-guide.md")).toBe(true);
20+
});
21+
22+
it("returns true for an empty string", () => {
23+
expect(isRealFileChange("")).toBe(true);
24+
});
25+
});
26+
27+
describe("filterRealChanges", () => {
28+
it("returns an empty array when given an empty array", () => {
29+
expect(filterRealChanges([])).toEqual([]);
30+
});
31+
32+
it("keeps all files when none are metadata", () => {
33+
const files = ["src/index.ts", "package.json", "tests/foo.test.ts"];
34+
expect(filterRealChanges(files)).toEqual(files);
35+
});
36+
37+
it("removes .oac/ metadata files", () => {
38+
const files = ["src/index.ts", ".oac/config.json", "README.md", ".oac/logs/run.log"];
39+
expect(filterRealChanges(files)).toEqual(["src/index.ts", "README.md"]);
40+
});
41+
42+
it("returns an empty array when all files are metadata", () => {
43+
const files = [".oac/a", ".oac/b/c"];
44+
expect(filterRealChanges(files)).toEqual([]);
45+
});
46+
});

0 commit comments

Comments
 (0)