import { describe, expect, it } from 'vitest'

import { useSharedTransitionStore } from '@/stores/sharedTransitionStore'

describe ('useSharedTransitionStore', () => {
  it ('sets and clears shared ids per location key', () => {
    useSharedTransitionStore.setState ({ byLocationKey: {} })

    useSharedTransitionStore.getState ().setForLocationKey ('loc-1', 'page-1')
    useSharedTransitionStore.getState ().setForLocationKey ('loc-2', 'page-2')

    expect (useSharedTransitionStore.getState ().byLocationKey).toEqual ({
      'loc-1': 'page-1',
      'loc-2': 'page-2',
    })

    useSharedTransitionStore.getState ().clearForLocationKey ('loc-1')

    expect (useSharedTransitionStore.getState ().byLocationKey).toEqual ({
      'loc-2': 'page-2',
    })
  })
})
