feat: 기능 추가 과정중
This commit is contained in:
@@ -3,8 +3,16 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
createApplication,
|
||||
type ApplicationOutputPorts,
|
||||
} from "../../src/application/create-application.js";
|
||||
import { createTestApplication } from "../helpers/create-test-application.js";
|
||||
} from "../../src/application/create-application.ts";
|
||||
import { createTestApplication } from "../helpers/create-test-application.ts";
|
||||
|
||||
declare module "../../src/application/ports/in/application-api.ts" {
|
||||
interface ApplicationFeatureInputs {
|
||||
"test-feature": Readonly<{
|
||||
run(): "ok";
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
describe("application input/output boundary", () => {
|
||||
it("exposes intent-oriented input APIs without leaking output ports", async () => {
|
||||
@@ -22,9 +30,11 @@ describe("application input/output boundary", () => {
|
||||
expect(application).not.toHaveProperty("telemetry");
|
||||
expect(application).not.toHaveProperty("releaseInfo");
|
||||
expect(application.features.has("not-installed")).toBe(false);
|
||||
expect(() => application.features.get("not-installed")).toThrow(
|
||||
"Application feature is not installed",
|
||||
);
|
||||
expect(() =>
|
||||
Reflect.apply(application.features.get, application.features, [
|
||||
"not-installed",
|
||||
]),
|
||||
).toThrow("Application feature is not installed");
|
||||
await expect(application.runtime.getReleaseSummary()).resolves.toEqual({
|
||||
buildId: "test-build",
|
||||
releaseId: "test-release",
|
||||
@@ -33,17 +43,34 @@ describe("application input/output boundary", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses fake output ports for preference, session, and safe diagnostics flows", () => {
|
||||
it("returns a typed input for an installed generic feature", () => {
|
||||
const featureInput = Object.freeze({
|
||||
run: () => "ok" as const,
|
||||
});
|
||||
const application = createTestApplication({
|
||||
featureInputs: { "test-feature": featureInput },
|
||||
});
|
||||
|
||||
expect(application.features.has("test-feature")).toBe(true);
|
||||
expect(application.features.get("test-feature")).toBe(featureInput);
|
||||
expect(application.features.get("test-feature").run()).toBe("ok");
|
||||
});
|
||||
|
||||
it("uses fake output ports for preference, session, and safe diagnostics flows", async () => {
|
||||
const write = vi.fn(() => ({ ok: true as const }));
|
||||
const emit = vi.fn();
|
||||
const record = vi.fn();
|
||||
const subscribe = vi.fn(() => () => {});
|
||||
const beginSignIn = vi.fn(async () => {});
|
||||
const signOut = vi.fn(async () => {});
|
||||
const recover = vi.fn(async () => "restored" as const);
|
||||
const ports = {
|
||||
session: {
|
||||
getState: () => "authenticated" as const,
|
||||
subscribe: () => () => {},
|
||||
beginSignIn: async () => {},
|
||||
signOut: async () => {},
|
||||
recover: async () => "restored" as const,
|
||||
subscribe,
|
||||
beginSignIn,
|
||||
signOut,
|
||||
recover,
|
||||
},
|
||||
preferences: {
|
||||
read: () => ({ ok: true as const, value: "dark" }),
|
||||
@@ -75,6 +102,14 @@ describe("application input/output boundary", () => {
|
||||
const application = createApplication(ports);
|
||||
|
||||
expect(application.session.getSnapshot()).toBe("authenticated");
|
||||
const listener = vi.fn();
|
||||
expect(application.session.subscribe(listener)).toBeTypeOf("function");
|
||||
expect(subscribe).toHaveBeenCalledWith(listener);
|
||||
await application.session.beginSignIn("/return");
|
||||
expect(beginSignIn).toHaveBeenCalledWith("/return");
|
||||
await application.session.signOut();
|
||||
expect(signOut).toHaveBeenCalledOnce();
|
||||
await expect(application.session.recover()).resolves.toBe("restored");
|
||||
expect(application.preferences.getColorScheme()).toBe("dark");
|
||||
expect(application.preferences.setColorScheme("light")).toEqual({ ok: true });
|
||||
expect(write).toHaveBeenCalledWith("COLOR_SCHEME", "light");
|
||||
|
||||
Reference in New Issue
Block a user