refactor: 프론트엔드 리펙토링
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
type InstalledHttpOperationExecutor,
|
||||
} from "../../../src/adapters/http/index.ts";
|
||||
import { createReferenceFeatureInstalledInput } from "../../../src/features/reference-feature/adapters/create-reference-feature-input.ts";
|
||||
|
||||
/**
|
||||
@@ -14,22 +17,31 @@ import { createReferenceFeatureInstalledInput } from "../../../src/features/refe
|
||||
describe("reference feature installed operation executor", () => {
|
||||
it("preserves the feature route id through the installed operation executor", async () => {
|
||||
const seen: Array<Readonly<Record<string, unknown>>> = [];
|
||||
const implementation = async (
|
||||
contract: Readonly<{ contract: Readonly<{ operationId: string }> }>,
|
||||
_input: unknown,
|
||||
context: Readonly<Record<string, unknown>>,
|
||||
) => {
|
||||
seen.push(Object.freeze({ ...context }));
|
||||
const value =
|
||||
contract.contract.operationId === "LIST_REFERENCE_RESOURCES"
|
||||
? []
|
||||
: {
|
||||
id: "resource-1",
|
||||
name: "Resource",
|
||||
};
|
||||
return Object.freeze({
|
||||
kind: "SUCCESS" as const,
|
||||
value,
|
||||
metadata: Object.freeze({ status: 200 }),
|
||||
effect: "NOT_APPLICABLE" as const,
|
||||
});
|
||||
};
|
||||
const execute = implementation as unknown as
|
||||
InstalledHttpOperationExecutor["execute"];
|
||||
|
||||
const installed = createReferenceFeatureInstalledInput({
|
||||
contractOperations: Object.freeze({
|
||||
async execute(
|
||||
_operationId: string,
|
||||
_input: unknown,
|
||||
context?: Readonly<Record<string, unknown>>,
|
||||
) {
|
||||
seen.push(Object.freeze({ ...(context ?? {}) }));
|
||||
return Object.freeze({
|
||||
kind: "SUCCESS" as const,
|
||||
value: [],
|
||||
metadata: Object.freeze({ status: 200 }),
|
||||
effect: "NOT_APPLICABLE" as const,
|
||||
});
|
||||
},
|
||||
}),
|
||||
http: Object.freeze({ execute }),
|
||||
});
|
||||
|
||||
await installed.input.listResources({ limit: 20 });
|
||||
|
||||
Reference in New Issue
Block a user