import { describe, it, expect } from 'vitest'
import { useLiteraturePreview } from '../useLiteraturePreview'

describe('useLiteraturePreview', () => {
  it('starts closed with null pmid', () => {
    const { previewPmid, showPreview } = useLiteraturePreview()
    expect(previewPmid.value).toBeNull()
    expect(showPreview.value).toBe(false)
  })

  it('openPreview sets pmid and shows', () => {
    const { previewPmid, showPreview, openPreview } = useLiteraturePreview()
    openPreview(12345)
    expect(previewPmid.value).toBe(12345)
    expect(showPreview.value).toBe(true)
  })

  it('closePreview resets state', () => {
    const { previewPmid, showPreview, openPreview, closePreview } = useLiteraturePreview()
    openPreview(12345)
    closePreview()
    expect(previewPmid.value).toBeNull()
    expect(showPreview.value).toBe(false)
  })
})
