Curated, product-agnostic snapshot of the post-story-04 tree: demo content deleted, auth-only reference feature, web-next shell, all gates green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor library traces, and product naming are curated out; generic template repairs (coverage provider devDeps, root test:coverage script, live lint fixes, root-only release-please) are kept. See TEMPLATE.md for provenance, curation list, and usage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import { describe, it } from "vitest";
|
|
import { RuleTester } from "eslint";
|
|
import path from "node:path";
|
|
import os from "node:os";
|
|
import fs from "node:fs";
|
|
import rule from "./usecase-must-have-test-file.js";
|
|
|
|
function makeUseCaseFixture({ withTest }) {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "umht-"));
|
|
const useCase = path.join(dir, "sign-in.use-case.ts");
|
|
fs.writeFileSync(
|
|
useCase,
|
|
`export const signInUseCase = () => async () => {};`,
|
|
);
|
|
if (withTest) {
|
|
fs.writeFileSync(
|
|
path.join(dir, "sign-in.use-case.test.ts"),
|
|
`import { it } from "vitest"; it("works", () => {});`,
|
|
);
|
|
}
|
|
return { useCase };
|
|
}
|
|
|
|
const tester = new RuleTester({
|
|
languageOptions: { ecmaVersion: "latest", sourceType: "module" },
|
|
});
|
|
|
|
describe("usecase-must-have-test-file", () => {
|
|
it("passes when a sibling .test.ts exists", () => {
|
|
const { useCase } = makeUseCaseFixture({ withTest: true });
|
|
tester.run("usecase-must-have-test-file", rule, {
|
|
valid: [{ filename: useCase, code: fs.readFileSync(useCase, "utf8") }],
|
|
invalid: [],
|
|
});
|
|
});
|
|
|
|
it("fires when no sibling test file exists", () => {
|
|
const { useCase } = makeUseCaseFixture({ withTest: false });
|
|
tester.run("usecase-must-have-test-file", rule, {
|
|
valid: [],
|
|
invalid: [
|
|
{
|
|
filename: useCase,
|
|
code: fs.readFileSync(useCase, "utf8"),
|
|
errors: [{ messageId: "missingTestFile" }],
|
|
},
|
|
],
|
|
});
|
|
});
|
|
});
|