mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 16:45:22 +00:00
28 lines
960 B
TypeScript
28 lines
960 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { inChildSessionContext, runInChildSessionContext } from "../src/child-context.js";
|
|
import subagentsExtension from "../src/index.js";
|
|
|
|
describe("child session async context", () => {
|
|
it("is scoped to the child async branch", async () => {
|
|
expect(inChildSessionContext()).toBe(false);
|
|
await runInChildSessionContext(async () => {
|
|
expect(inChildSessionContext()).toBe(true);
|
|
await Promise.resolve();
|
|
expect(inChildSessionContext()).toBe(true);
|
|
});
|
|
expect(inChildSessionContext()).toBe(false);
|
|
});
|
|
|
|
it("prevents a child resource load from creating another extension manager", async () => {
|
|
const pi = new Proxy({}, {
|
|
get: vi.fn(() => {
|
|
throw new Error("child extension factory must be a no-op");
|
|
}),
|
|
});
|
|
|
|
await runInChildSessionContext(async () => {
|
|
expect(() => subagentsExtension(pi as any)).not.toThrow();
|
|
});
|
|
});
|
|
});
|