invariant.spec.ts 1.1 KB

123456789101112131415161718192021222324252627
  1. // @vitest-environment jsdom
  2. import { describe, expect, it } from 'vitest'
  3. import { Context } from 'cordis'
  4. import { apply as nodeApply } from '@deepseek-ai/dsh-client-ui-theme'
  5. import { apply as clientApply, inject, ThemeService } from '@deepseek-ai/dsh-client-ui-theme/client'
  6. import * as ThemeInvariant from '@deepseek-ai/dsh-client-ui-theme/invariant'
  7. import InvariantService from '@deepseek-ai/dsh-invariants'
  8. describe('invariant companion', () => {
  9. it('registers under the package name with an empty installer', async () => {
  10. const ctx = new Context()
  11. await ctx.plugin(InvariantService, { enabled: true })
  12. await expect(ctx.plugin(ThemeInvariant).await()).resolves.toBeDefined()
  13. })
  14. it('node-half apply is a no-op host placeholder', () => {
  15. nodeApply()
  16. expect(true).toBe(true) // reaching here without throw is the contract
  17. })
  18. it('client apply provides ctx.theme with no service prerequisites', async () => {
  19. expect(inject).toEqual([])
  20. const ctx = new Context()
  21. await ctx.plugin({ inject, apply: clientApply }).await()
  22. expect(ctx.get('theme')).toBeInstanceOf(ThemeService)
  23. })
  24. })