feat: implement OpenBrain ContextEngine plugin
This commit is contained in:
30
tests/register.test.ts
Normal file
30
tests/register.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user