Files
clean-architecture-frontend…/tests/unit/feature-module.test.ts
DongHyeonka 3686f92cd1 test(features): 플랫폼 시험을 tests/unit으로 옮기고 죽은 가드를 지운다
기능 시험 자리인 tests/features 바로 아래에 플랫폼 단위 시험 둘과,
지워진 참조 기능의 상수 이름만 보는 가드가 있다.

둘은 tests/unit으로 옮기고 가드는 지운다. 상수 이름을 바꿔 가드를
살리는 안은 참조 기능이 없는 템플릿에서 볼 대상이 없어 쓰지 않는다.
문서들이 가리키는 tests/features 폴더는 .gitkeep으로 남긴다(없으면
verify:documentation이 실패한다). 게이트 배선 시험은 옮긴 파일의 옛
경로 대신 가짜임이 보이는 probe 경로로 tests/features를 본다.

REFERENCE_* 이름 금지는 없어진다. 중앙 파일의 기능 import 가운데
loaded-feature-runtimes와 type-only import는 지운 가드도 막지 않았고
지금도 막는 검사가 없다(별도 제안).

검증: 노트북 test:unit·verify:documentation이 통과한다. test:coverage
에서 tests/features를 빼면 게이트 배선 시험이 실패한다.

Refs: REV-FE-0021
2026-11-22 21:28:49 +09:00

48 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
defineFeatureModule,
loadFeatureRuntime,
} from "../../src/features/feature-module.ts";
const runtimeOf = async (featureId: string) => ({
featureId,
schemas: {},
adapters: [],
contractContributions: [],
});
describe("defineFeatureModule", () => {
it("keeps one stable feature id and freezes the descriptor", () => {
const module = defineFeatureModule({
id: "feature-a",
contracts: { featureId: "feature-a" },
routes: {}, messages: {}, loadRuntime: () => runtimeOf("feature-a"),
});
expect(module.id).toBe("feature-a");
expect(Object.isFrozen(module)).toBe(true);
});
// 09-11: the one check defineFeatureModule makes at runtime.
it("rejects a module whose id differs from its contract featureId", () => {
expect(() =>
defineFeatureModule({
id: "feature-a",
contracts: { featureId: "feature-b" },
routes: {}, messages: {}, loadRuntime: () => runtimeOf("feature-a"),
}),
).toThrow("Feature module id feature-a does not match contract featureId feature-b");
});
// 15-01: the runtime half is loaded lazily, so its owner is checked on load.
it("refuses a runtime half that belongs to another feature", async () => {
const module = defineFeatureModule({
id: "feature-a",
contracts: { featureId: "feature-a" },
routes: {}, messages: {}, loadRuntime: () => runtimeOf("feature-b"),
});
await expect(loadFeatureRuntime(module)).rejects.toThrow(
"Feature module feature-a loaded the runtime of feature-b",
);
});
});