import { describe, expect, it } from 'vitest'
import { getErrorMessage } from '../get-error-message'

describe('getErrorMessage', () => {
  it('returns error message for Error instance', () => {
    expect(getErrorMessage(new Error('test error'))).toBe('test error')
  })

  it('returns fallback for non-Error', () => {
    expect(getErrorMessage('string error')).toBe('Произошла ошибка')
  })

  it('returns custom fallback when provided', () => {
    expect(getErrorMessage(null, 'custom')).toBe('custom')
  })

  it('returns fallback for Error with empty message', () => {
    expect(getErrorMessage(new Error(''), 'empty')).toBe('empty')
  })
})
