import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { TransferItemTable } from '../transfer-item-table';
const baseItem = {
id: 'i1',
name: 'Tủ lạnh Toshiba',
brand: 'Toshiba',
modelName: 'GR-RT624WE-PMV',
category: 'APPLIANCE' as const,
condition: 'GOOD' as const,
purchaseYear: 2022,
originalPriceVND: '15000000',
askingPriceVND: '8000000',
aiEstimatePriceVND: '7500000',
aiConfidence: 0.85,
quantity: 1,
};
describe('TransferItemTable', () => {
it('renders empty state when no items', () => {
render();
expect(
screen.getByText('Chưa có danh sách vật phẩm.'),
).toBeInTheDocument();
});
it('renders all column headers', () => {
render();
expect(screen.getByText('Tên')).toBeInTheDocument();
expect(screen.getByText('Loại')).toBeInTheDocument();
expect(screen.getByText('Tình trạng')).toBeInTheDocument();
expect(screen.getByText('Thương hiệu')).toBeInTheDocument();
expect(screen.getByText('SL')).toBeInTheDocument();
expect(screen.getByText('Giá yêu cầu')).toBeInTheDocument();
expect(screen.getByText('Giá AI')).toBeInTheDocument();
});
it('renders item row with localized currency formatting', () => {
render();
expect(screen.getByText('Tủ lạnh Toshiba')).toBeInTheDocument();
expect(screen.getByText('GR-RT624WE-PMV')).toBeInTheDocument();
expect(screen.getByText(/8\.000\.000/)).toBeInTheDocument();
expect(screen.getByText(/7\.500\.000/)).toBeInTheDocument();
});
it('falls back to em-dash for missing brand and AI estimate', () => {
render(
,
);
const dashes = screen.getAllByText('—');
expect(dashes.length).toBeGreaterThanOrEqual(2);
});
});