From fef4313685fcd384b7c5eed7a4628b087e95dd14 Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Thu, 9 Jul 2026 11:04:34 +0800 Subject: [PATCH] test(spill-policy): guard loader export shape --- .../spill/spill-policy/tests/spill-policy.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/spill/spill-policy/tests/spill-policy.spec.ts b/packages/spill/spill-policy/tests/spill-policy.spec.ts index b137a73144..b0678c27c2 100644 --- a/packages/spill/spill-policy/tests/spill-policy.spec.ts +++ b/packages/spill/spill-policy/tests/spill-policy.spec.ts @@ -10,6 +10,7 @@ import { describe, expect, it, vi } from 'vitest' import { Context } from 'cordis' +import Loader from '@cordisjs/plugin-loader' import { CallId } from '@deepseek-ai/dsh-llm' import type { ContentBlock } from '@deepseek-ai/dsh-llm' import { SessionId } from '@deepseek-ai/dsh-session' @@ -82,6 +83,20 @@ describe('disabled mode', () => { }) }) +describe('loader export shape', () => { + it('has no default export and keeps name/inject/Config through unwrapExports', () => { + expect('default' in SpillPolicy).toBe(false) + + const loader = Object.create(Loader.prototype) as Loader + const unwrapped = loader.unwrapExports(SpillPolicy) as Record + expect(unwrapped).toBe(SpillPolicy) + expect(unwrapped.name).toBe('spill-policy') + expect(unwrapped.inject).toEqual(['tools']) + expect(unwrapped.Config).toBeDefined() + expect(typeof unwrapped.apply).toBe('function') + }) +}) + describe('config validation', () => { it('rejects a negative maxInlineBytes at load', async () => { await expect(setup({ maxInlineBytes: -1 })).rejects.toThrow(/non-negative integer/)