Files
pi-dev-tools/src/profiles.test.ts
2026-04-10 23:11:54 +01:00

27 lines
792 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { resolveProfileForPath } from "./profiles.ts";
test("resolveProfileForPath finds the first matching profile and nearest workspace root", () => {
const result = resolveProfileForPath(
{
defaults: {},
profiles: [
{
name: "typescript",
match: ["src/**/*.ts"],
workspaceRootMarkers: ["package.json", "tsconfig.json"],
formatter: { kind: "command", command: ["biome", "format", "--write", "{file}"] },
diagnostics: [],
},
],
},
"/repo/src/app.ts",
"/repo",
["/repo/package.json", "/repo/src/app.ts"],
);
assert.equal(result?.profile.name, "typescript");
assert.equal(result?.workspaceRoot, "/repo");
});