22301014 | 3d96630 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 1 | import { render, screen } from '@testing-library/react'; |
| 2 | import OtherCategory from '../../feature/categories/OtherCategory'; |
| 3 | import { Provider } from 'react-redux'; |
| 4 | import { store } from '../../store/store'; |
| 5 | import { MemoryRouter } from 'react-router'; |
| 6 | |
| 7 | describe('OtherCategory Component', () => { |
| 8 | it('renders other resources category page with search and resource cards', () => { |
| 9 | render( |
| 10 | <MemoryRouter> |
| 11 | <Provider store={store}> |
| 12 | <OtherCategory /> |
| 13 | </Provider> |
| 14 | </MemoryRouter> |
| 15 | ); |
| 16 | |
| 17 | // 验证标题和描述 |
| 18 | expect(screen.getByText('其他资源分区')).toBeInTheDocument(); |
| 19 | expect(screen.getByText('软件、电子书等其他类型资源')).toBeInTheDocument(); |
| 20 | |
| 21 | // 验证搜索框 |
| 22 | const searchInput = screen.getByPlaceholderText('搜索资源名称或描述'); |
| 23 | expect(searchInput).toBeInTheDocument(); |
| 24 | |
| 25 | // 验证资源卡片 |
| 26 | expect(screen.getByText('盗梦空间')).toBeInTheDocument(); |
| 27 | expect(screen.getByText('肖申克的救赎')).toBeInTheDocument(); |
| 28 | |
| 29 | // 验证类型信息 |
| 30 | expect(screen.getByText('类型: 未知类型')).toBeInTheDocument(); |
| 31 | }); |
| 32 | }); |