host.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { Context } from 'cordis'
  2. import { describe, expect, it } from 'vitest'
  3. import { Settings, settingsNamespace, type SettingsNamespace } from '@deepseek-ai/dsh-settings'
  4. import { apply } from '../src/index.ts'
  5. import { WELCOME_NOTICE_SETTINGS_NAMESPACE } from '../src/onboarding-copy.ts'
  6. class MemorySettings extends Settings {
  7. readonly writable = true
  8. protected load(): Promise<Record<string, unknown>> { return Promise.resolve({}) }
  9. protected persist(_ns: SettingsNamespace, _section: Record<string, unknown>): Promise<void> {
  10. return Promise.resolve()
  11. }
  12. }
  13. describe('ui-settings-general host', () => {
  14. it('registers and disposes the durable onboarding namespace with its fiber', async () => {
  15. const ctx = new Context()
  16. await ctx.plugin(MemorySettings).await()
  17. const fiber = ctx.plugin({ apply })
  18. await fiber.await()
  19. expect(ctx.settings.describe().map(row => row.ns)).toContain(
  20. settingsNamespace(WELCOME_NOTICE_SETTINGS_NAMESPACE),
  21. )
  22. await fiber.dispose()
  23. expect(ctx.settings.describe().map(row => row.ns)).not.toContain(
  24. settingsNamespace(WELCOME_NOTICE_SETTINGS_NAMESPACE),
  25. )
  26. })
  27. })