plugin-shape.spec.ts 951 B

12345678910111213141516171819202122
  1. import { describe, expect, it } from 'vitest'
  2. import Loader from '@deepseek-ai/cordis-plugin-loader'
  3. import * as jsonrpc from '../src/index.ts'
  4. /**
  5. * Run the real namespace export through `Loader.unwrapExports`; a stray
  6. * default would discard `name`, `inject`, `Config`, and `apply`.
  7. */
  8. describe('dsh-sdk-jsonrpc-server plugin export shape', () => {
  9. it('has the namespace-plugin export shape (no stray default) so the Loader keeps name/inject/Config/apply', () => {
  10. expect('default' in jsonrpc).toBe(false)
  11. expect(typeof jsonrpc.apply).toBe('function')
  12. const loader = Object.create(Loader.prototype) as Loader
  13. const unwrapped = loader.unwrapExports(jsonrpc) as Record<string, unknown>
  14. expect(unwrapped).toBe(jsonrpc)
  15. expect(unwrapped.name).toBe('sdk-jsonrpc-server')
  16. expect(unwrapped.inject).toEqual(['agents'])
  17. expect(unwrapped.Config).toBeDefined()
  18. expect(typeof unwrapped.apply).toBe('function')
  19. })
  20. })