/**
 * (ApiResourceTable forwards to shared TableView stub).
 */
import React from 'react'
import { render, screen } from '@testing-library/react'
import ApiResourceTable from '../index'

jest.mock('next-intl', () => ({ useTranslations: () => (k: string) => k }))
jest.mock('@/i18n/navigation', () => ({
  useRouter: () => ({ push: jest.fn(), back: jest.fn() }),
}))
jest.mock('@/share/components/table', () => ({
  TableView: () => <div>TableView</div>,
}))

describe('[components/api-product/detail/about/table] ApiResourceTable', () => {
  it('delegates to TableView when resources is empty', () => {
    render(<ApiResourceTable resources={[]} />)
    // Component always renders the table (even when empty)
    expect(screen.getByText('TableView')).toBeInTheDocument()
  })

  it('delegates to TableView when resources provided', () => {
    render(
      <ApiResourceTable
        resources={[
          { target: '/payment', verb: 'GET' },
          { target: '/transfer', verb: 'POST' },
        ]}
      />
    )
    expect(screen.getByText('TableView')).toBeInTheDocument()
  })

  it('delegates when resources prop omitted (defaults empty)', () => {
    render(<ApiResourceTable />)
    expect(screen.getByText('TableView')).toBeInTheDocument()
  })
})
