| import { render, screen } from '@testing-library/react'; |
| import OtherCategory from '../../feature/categories/OtherCategory'; |
| import { Provider } from 'react-redux'; |
| import { store } from '../../store/store'; |
| import { MemoryRouter } from 'react-router'; |
| |
| describe('OtherCategory Component', () => { |
| it('renders other resources category page with search and resource cards', () => { |
| render( |
| <MemoryRouter> |
| <Provider store={store}> |
| <OtherCategory /> |
| </Provider> |
| </MemoryRouter> |
| ); |
| |
| // 验证标题和描述 |
| expect(screen.getByText('其他资源分区')).toBeInTheDocument(); |
| expect(screen.getByText('软件、电子书等其他类型资源')).toBeInTheDocument(); |
| |
| // 验证搜索框 |
| const searchInput = screen.getByPlaceholderText('搜索资源名称或描述'); |
| expect(searchInput).toBeInTheDocument(); |
| |
| // 验证资源卡片 |
| expect(screen.getByText('盗梦空间')).toBeInTheDocument(); |
| expect(screen.getByText('肖申克的救赎')).toBeInTheDocument(); |
| |
| // 验证类型信息 |
| expect(screen.getByText('类型: 未知类型')).toBeInTheDocument(); |
| }); |
| }); |