pdf-store.client.spec.ts 1.0 KB

12345678910111213141516171819202122232425
  1. /** PDF view preferences survive body remounts without sharing state between tabs. */
  2. import { describe, expect, it } from 'vitest'
  3. import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit'
  4. import { createPdfStore } from '../src/client/pdf/store.ts'
  5. describe('PDF view store', () => {
  6. it('keeps the last visible page for each tab and forgets only the closed tab', () => {
  7. const instance = createPdfStore().create()
  8. const one = 'one' as TabId
  9. const two = 'two' as TabId
  10. instance.actions.page(one, 3)
  11. instance.actions.page(two, 2)
  12. expect(instance.getSnapshot().byTab).toEqual({ one: { page: 3 }, two: { page: 2 } })
  13. instance.actions.forget(one)
  14. expect(instance.getSnapshot().byTab).toEqual({ two: { page: 2 } })
  15. })
  16. it('creates independent Session store instances', () => {
  17. const store = createPdfStore()
  18. const first = store.create()
  19. const second = store.create()
  20. first.actions.page('same-tab' as TabId, 2)
  21. expect(second.getSnapshot().byTab).toEqual({})
  22. })
  23. })