admin/components/paginated-list/PaginatedListCards.test.tsx
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

43 lines
1.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import type { PaginationListColumnType } from '@/types'
import PaginatedListCards from '@/components/paginated-list/PaginatedListCards'
const columns: PaginationListColumnType[] = [
{ field: 'name', label: 'نام' },
{ field: 'status', label: 'وضعیت' },
{ field: 'actions', label: 'عملیات' },
]
describe('PaginatedListCards', () => {
it('renders row fields and actions as a mobile card', () => {
render(
<PaginatedListCards
columns={columns}
data={[{ id: '1', name: 'رویداد نمونه', status: 'فعال' }]}
isLoading={false}
onRenderCell={(item, key) => (key === 'actions' ? <button type="button">مشاهده</button> : String(item[String(key)] ?? '—'))}
/>
)
expect(screen.getByRole('article')).toBeInTheDocument()
expect(screen.getByText('نام')).toBeInTheDocument()
expect(screen.getByText('رویداد نمونه')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'مشاهده' })).toBeInTheDocument()
})
it('renders the shared empty state when there are no rows', () => {
render(
<PaginatedListCards
columns={columns}
data={[]}
isLoading={false}
onRenderCell={() => null}
/>
)
expect(screen.getByText('اطلاعاتی برای نمایش وجود ندارد')).toBeInTheDocument()
})
})