import { describe, expect, it } from 'vitest'
import { resolvePoseAssetId } from './narrativeRepository.js'

describe('resolvePoseAssetId', () => {
  const poses = { neutral: 'asset-neutral', concerned: 'asset-concerned', missing: null }

  it('returns the requested pose asset when present', () => {
    expect(resolvePoseAssetId(poses, 'concerned', 'neutral')).toBe('asset-concerned')
  })
  it('falls back to the NPC default pose when the requested pose is absent', () => {
    expect(resolvePoseAssetId(poses, 'pointing', 'neutral')).toBe('asset-neutral')
  })
  it('falls back to the default when the requested pose exists but has no artwork', () => {
    expect(resolvePoseAssetId(poses, 'missing', 'neutral')).toBe('asset-neutral')
  })
  it('returns null (no artwork) when neither requested nor default resolves', () => {
    expect(resolvePoseAssetId(poses, 'pointing', 'also-missing')).toBeNull()
    expect(resolvePoseAssetId(poses, null, null)).toBeNull()
    expect(resolvePoseAssetId({}, 'neutral', 'neutral')).toBeNull()
  })
})
