mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-24 05:22:58 +00:00
refactor: consume Commonlib as a package
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { eventHub } from "@/common/events";
|
||||
import { translateLiveSyncMessage } from "@/common/translation";
|
||||
import { observeServiceContext } from "../../../test/contracts/serviceContext";
|
||||
import { ObsidianServiceContext } from "./ObsidianServiceContext";
|
||||
|
||||
const TRANSLATION_KEY = "Replicator.Message.InitialiseFatalError";
|
||||
|
||||
describe("ObsidianServiceContext contract", () => {
|
||||
it("preserves the plug-in capabilities and host-neutral API results", () => {
|
||||
type Parameters = ConstructorParameters<typeof ObsidianServiceContext>;
|
||||
const app = {} as Parameters[0];
|
||||
const plugin = {} as Parameters[1];
|
||||
const liveSyncPlugin = {} as Parameters[2];
|
||||
const context = new ObsidianServiceContext(app, plugin, liveSyncPlugin);
|
||||
|
||||
expect(observeServiceContext(context, TRANSLATION_KEY)).toEqual({
|
||||
translation: translateLiveSyncMessage(TRANSLATION_KEY),
|
||||
receivedEvents: ["context-contract-event"],
|
||||
});
|
||||
expect(context.events).toBe(eventHub);
|
||||
expect(context.app).toBe(app);
|
||||
expect(context.plugin).toBe(plugin);
|
||||
expect(context.liveSyncPlugin).toBe(liveSyncPlugin);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user