plugin.spec.ts 1013 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * The settings domain base plugin's own mounting behavior: it stands up
  3. * `ctx.settingsScope` for every feature that owns a preference row, and the
  4. * service retires with its fiber.
  5. */
  6. import { Context } from '@deepseek-ai/cordis'
  7. import { describe, expect, it } from 'vitest'
  8. import { apply, inject, SettingsScopeService } from '../src/client/index.ts'
  9. /** Boot the browser half over a bare root context; it injects nothing. */
  10. function bench() {
  11. const ctx = new Context()
  12. return { ctx, fiber: ctx.plugin({ inject: [...inject], apply }) }
  13. }
  14. describe('settings domain base plugin', () => {
  15. it('mounts the scope service under settingsScope', async () => {
  16. const { ctx, fiber } = bench()
  17. await fiber.await()
  18. expect(ctx.get('settingsScope')).toBeInstanceOf(SettingsScopeService)
  19. })
  20. it('fiber disposal retires the service', async () => {
  21. const { ctx, fiber } = bench()
  22. await fiber.await()
  23. await fiber.dispose()
  24. expect(ctx.get('settingsScope')).toBeUndefined()
  25. })
  26. })