|
| 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