import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import { createI18n } from 'vue-i18n'

import ReservationStatusBadge from '@/components/reservation/ReservationStatusBadge.vue'
import zhCN from '@/i18n/locales/zh-CN'

function mountWithI18n(status: string) {
  const i18n = createI18n({
    legacy: false,
    locale: 'zh-CN',
    messages: {
      'zh-CN': zhCN,
    },
  })

  return mount(ReservationStatusBadge, {
    props: {
      status,
    },
    global: {
      plugins: [i18n],
    },
  })
}

describe('ReservationStatusBadge', () => {
  it('renders stable status code through i18n label', () => {
    const wrapper = mountWithI18n('PENDING_CONFIRM')

    expect(wrapper.text()).toContain('待确认')
    expect(wrapper.classes()).toContain('status-badge--info')
  })

  it('falls back to a localized unknown status label', () => {
    const wrapper = mountWithI18n('UNKNOWN_STATUS')

    expect(wrapper.text()).toContain('未知状态')
    expect(wrapper.text()).not.toContain('UNKNOWN_STATUS')
  })
})
