Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
31 lines
893 B
TypeScript
31 lines
893 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { OPENBRAIN_CONTEXT_ENGINE_ID, register } from "../src/index.js";
|
|
|
|
describe("plugin register()", () => {
|
|
it("registers the openbrain context engine factory", async () => {
|
|
const registerContextEngine = vi.fn();
|
|
|
|
register({
|
|
registerContextEngine,
|
|
pluginConfig: {
|
|
baseUrl: "https://brain.example.com",
|
|
apiKey: "secret",
|
|
},
|
|
logger: {
|
|
debug: vi.fn(),
|
|
info: vi.fn(),
|
|
warn: vi.fn(),
|
|
error: vi.fn(),
|
|
},
|
|
});
|
|
|
|
expect(registerContextEngine).toHaveBeenCalledTimes(1);
|
|
const [id, factory] = registerContextEngine.mock.calls[0] as [string, () => Promise<unknown> | unknown];
|
|
expect(id).toBe(OPENBRAIN_CONTEXT_ENGINE_ID);
|
|
|
|
const engine = await factory();
|
|
expect(engine).toHaveProperty("info.id", OPENBRAIN_CONTEXT_ENGINE_ID);
|
|
});
|
|
});
|