test: enforce exact TechLog contract keys
This commit is contained in:
@@ -5,29 +5,23 @@ import {
|
||||
TECH_LOG_FEATURE_ID,
|
||||
type TechLogFeatureInput,
|
||||
} from "../../../src/features/tech-log/application/tech-log-feature-input.ts";
|
||||
import type { PublicContentQueries } from "../../../src/features/tech-log/application/ports/public-content-queries.ts";
|
||||
import type { StudioGateway } from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
||||
|
||||
function acceptsApplicationFeatureInput(
|
||||
input: ApplicationFeatureInputs["tech-log"],
|
||||
): TechLogFeatureInput {
|
||||
return input;
|
||||
}
|
||||
type Equal<Left, Right> =
|
||||
(<Value>() => Value extends Left ? 1 : 2) extends
|
||||
(<Value>() => Value extends Right ? 1 : 2)
|
||||
? true
|
||||
: false;
|
||||
type Assert<Condition extends true> = Condition;
|
||||
|
||||
type TechLogFeatureInputExposesNoMissingOrAdditionalKeys = Assert<
|
||||
Equal<keyof ApplicationFeatureInputs["tech-log"], "publicContent" | "createStudioGateway">
|
||||
>;
|
||||
type TechLogFeatureInputRegistryValueMatchesFeatureContract = Assert<
|
||||
Equal<ApplicationFeatureInputs["tech-log"], TechLogFeatureInput>
|
||||
>;
|
||||
|
||||
describe("TechLog feature input", () => {
|
||||
it("uses the fixed application feature identifier", () => {
|
||||
expect(TECH_LOG_FEATURE_ID).toBe("tech-log");
|
||||
});
|
||||
|
||||
it("accepts public queries and a Studio gateway factory through the application registry", () => {
|
||||
const publicContent = {} as PublicContentQueries;
|
||||
const gateway = {} as StudioGateway;
|
||||
const input = acceptsApplicationFeatureInput({
|
||||
publicContent,
|
||||
createStudioGateway: () => gateway,
|
||||
});
|
||||
|
||||
expect(input.publicContent).toBe(publicContent);
|
||||
expect(input.createStudioGateway()).toBe(gateway);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user