chat-store.client.spec.ts 958 B

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from 'vitest'
  2. import { createChatStore } from '../src/client/stores.ts'
  3. describe('createChatStore', () => {
  4. it('starts without a selected Chat target', () => {
  5. const store = createChatStore().create()
  6. expect(store.store.getSnapshot()).toEqual({ selection: null })
  7. })
  8. it('selects and clears one Chat details target', () => {
  9. const store = createChatStore().create()
  10. store.actions.select({ turnSeq: 3, callId: 'c1', toolName: 'bash' })
  11. expect(store.store.getSnapshot().selection)
  12. .toEqual({ turnSeq: 3, callId: 'c1', toolName: 'bash' })
  13. store.actions.select(null)
  14. expect(store.store.getSnapshot().selection).toBeNull()
  15. })
  16. it('creates independent instances', () => {
  17. const handle = createChatStore()
  18. const first = handle.create()
  19. const second = handle.create()
  20. first.actions.select({ turnSeq: 1 })
  21. expect(second.store.getSnapshot().selection).toBeNull()
  22. })
  23. })