| import { render, screen } from '@testing-library/react'; |
| import MovieCategory from '../../feature/categories/MovieCategory'; |
| import { Provider } from 'react-redux'; |
| import { store } from '../../store/store'; |
| import { MemoryRouter } from 'react-router'; |
| |
| describe('MovieCategory Component', () => { |
| it('renders movie category page with search and movie cards', () => { |
| render( |
| <MemoryRouter> |
| <Provider store={store}> |
| <MovieCategory /> |
| </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(); |
| expect(screen.getByText('导演: 弗兰克·德拉邦特')).toBeInTheDocument(); |
| }); |
| }); |