test: skip auto-format in edit tests via setFormatCache helper

- Add setFormatCache() to auto-format.ts for test overrides
- Use setFormatCache(null) in edit-languages and edit-stack tests
  to prevent format detection from interfering with test assertions

Co-Authored-By: SoulForge <[email protected]>
This commit is contained in:
PouiiroandSoulForge committed 2026-03-30 18:29:22 +02:00
1 parent 52b0b36ed6
commit 7a2d02e90d
3 files changed
+9

No files matched your search

+5
View File
@@ -22,6 +22,11 @@ export function resetFormatCache(): void {
cachedFormatCmd = undefined;
}
/** Override cached format command (e.g. set to null in tests to skip formatting). */
export function setFormatCache(cmd: string | null): void {
cachedFormatCmd = cmd;
}
/**
* Auto-format a file after edit. Returns true if formatted, false if skipped/failed.
* Uses cached format command to avoid re-detecting project profile on every edit.
+2
View File
@@ -2,6 +2,7 @@ import { describe, expect, it, beforeEach, afterAll } from "bun:test";
import { clearEditStacks, undoEditTool } from "../src/core/tools/edit-stack.js";
import { editFileTool } from "../src/core/tools/edit-file.js";
import { multiEditTool } from "../src/core/tools/multi-edit.js";
import { setFormatCache } from "../src/core/tools/auto-format.js";
import { writeFile, mkdir, rm } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
@@ -16,6 +17,7 @@ async function writeTestFile(name: string, content: string): Promise<string> {
beforeEach(async () => {
clearEditStacks();
setFormatCache(null);
await mkdir(TMP, { recursive: true });
});
+2
View File
@@ -7,6 +7,7 @@ import {
} from "../src/core/tools/edit-stack.js";
import { editFileTool, buildRichEditError } from "../src/core/tools/edit-file.js";
import { multiEditTool } from "../src/core/tools/multi-edit.js";
import { setFormatCache } from "../src/core/tools/auto-format.js";
import { writeFile, mkdir, rm } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
@@ -21,6 +22,7 @@ async function writeTestFile(name: string, content: string): Promise<string> {
beforeEach(async () => {
clearEditStacks();
setFormatCache(null);
await mkdir(TMP, { recursive: true });
});