blob: ad42353df311e6c92c8acbef1e09efecd4e04d31 [file] [log] [blame]
223010143d966302025-06-07 22:54:40 +08001import { render, screen } from '@testing-library/react';
2import GameCategory from '../../feature/categories/GameCategory';
3import { Provider } from 'react-redux';
4import { store } from '../../store/store';
5import { MemoryRouter } from 'react-router';
6
7describe('GameCategory Component', () => {
8 it('renders game category page with search and game cards', () => {
9 render(
10 <MemoryRouter>
11 <Provider store={store}>
12 <GameCategory />
13 </Provider>
14 </MemoryRouter>
15 );
16
17 // 验证标题和描述
18 expect(screen.getByText('游戏资源分区')).toBeInTheDocument();
19 expect(screen.getByText('PC、主机游戏资源分享')).toBeInTheDocument();
20
21 // 验证搜索框
22 const searchInput = screen.getByPlaceholderText('搜索游戏名称或开发商');
23 expect(searchInput).toBeInTheDocument();
24
25 // 验证游戏卡片
26 expect(screen.getByText('赛博朋克2077')).toBeInTheDocument();
27 expect(screen.getByText('艾尔登法环')).toBeInTheDocument();
28
29 // 验证开发商信息
30 expect(screen.getByText('开发商: CD Projekt Red')).toBeInTheDocument();
31 expect(screen.getByText('开发商: FromSoftware')).toBeInTheDocument();
32 });
33});