view-selection.client.spec.ts 765 B

1234567891011121314151617181920
  1. import { describe, expect, it } from 'vitest'
  2. import { resolveActiveView } from '../src/client/view-selection.ts'
  3. import type { ViewTab } from '../src/client/contract/views.ts'
  4. describe('resolveActiveView', () => {
  5. it('resolves the preferred registered View and Chat fallback', () => {
  6. const tabs: readonly ViewTab[] = [
  7. { id: 'chat', label: 'Chat' },
  8. { id: 'custom', label: 'Custom' },
  9. ]
  10. expect(resolveActiveView(tabs, 'custom')?.id).toBe('custom')
  11. expect(resolveActiveView(tabs, 'removed')?.id).toBe('chat')
  12. expect(resolveActiveView(tabs, null)?.id).toBe('chat')
  13. })
  14. it('does not choose an arbitrary registered View', () => {
  15. expect(resolveActiveView([{ id: 'custom', label: 'Custom' }], null)).toBeUndefined()
  16. })
  17. })