mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
Narrow service and command composition
This commit is contained in:
1 parent
273079e827
commit
4027417bf5
22 files changed
+928
-202
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, expectTypeOf, it, vi } from "vitest";
|
||||
import type {
|
||||
NecessaryServices,
|
||||
NecessaryServicesInterfaces,
|
||||
} from "@vrtmrz/livesync-commonlib/compat/interfaces/ServiceModule";
|
||||
import {
|
||||
COMPATIBILITY_PAUSE_SETTING_MESSAGE,
|
||||
DATABASE_COMPATIBILITY_VERSION_KEY,
|
||||
@@ -101,6 +105,32 @@ function createFixture(
|
||||
}
|
||||
|
||||
describe("compatibility review controller", () => {
|
||||
it("accepts operation services without retaining an application-core contract", () => {
|
||||
type Dependencies = NecessaryServicesInterfaces<"setting" | "config" | "vault" | "control", never>;
|
||||
type ControllerHost = ConstructorParameters<typeof CompatibilityReviewController>[0];
|
||||
|
||||
expectTypeOf<Dependencies>().toExtend<ControllerHost>();
|
||||
expectTypeOf<keyof ControllerHost>().toEqualTypeOf<"services" | "serviceModules">();
|
||||
expectTypeOf<keyof ControllerHost["services"]>().toEqualTypeOf<"setting" | "config" | "vault" | "control">();
|
||||
expectTypeOf<keyof ControllerHost["serviceModules"]>().toBeNever();
|
||||
});
|
||||
|
||||
it("composes the review from its operation services and lifecycle and command ports", () => {
|
||||
type Dependencies = NecessaryServices<
|
||||
"setting" | "config" | "vault" | "control" | "appLifecycle" | "API",
|
||||
never
|
||||
>;
|
||||
type FeatureHost = Parameters<typeof useCompatibilityReview>[0];
|
||||
|
||||
expectTypeOf<Dependencies>().toExtend<FeatureHost>();
|
||||
expectTypeOf<keyof FeatureHost>().toEqualTypeOf<"services" | "serviceModules">();
|
||||
expectTypeOf<keyof FeatureHost["services"]>().toEqualTypeOf<
|
||||
"context" | "setting" | "config" | "vault" | "control" | "appLifecycle" | "API"
|
||||
>();
|
||||
expectTypeOf<keyof FeatureHost["serviceModules"]>().toBeNever();
|
||||
expectTypeOf<ReturnType<typeof useCompatibilityReview>>().toEqualTypeOf<CompatibilityReviewController>();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user