22301014 | 3d96630 | 2025-06-07 22:54:40 +0800 | [diff] [blame^] | 1 | import { render, screen } from '@testing-library/react'; |
| 2 | import MusicCategory from '../../feature/categories/MusicCategory'; |
| 3 | import { Provider } from 'react-redux'; |
| 4 | import { store } from '../../store/store'; |
| 5 | import { MemoryRouter } from 'react-router'; |
| 6 | |
| 7 | describe('MusicCategory Component', () => { |
| 8 | it('renders music category page with search, filters and music cards', () => { |
| 9 | render( |
| 10 | <MemoryRouter> |
| 11 | <Provider store={store}> |
| 12 | <MusicCategory /> |
| 13 | </Provider> |
| 14 | </MemoryRouter> |
| 15 | ); |
| 16 | |
| 17 | // 验证标题和描述 |
| 18 | expect(screen.getByText('音乐资源分区')).toBeInTheDocument(); |
| 19 | expect(screen.getByText('高质量音乐资源共享,保持分享率,共建良好PT环境')).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 | expect(screen.getByText('FLAC')).toBeInTheDocument(); |
| 29 | |
| 30 | // 验证分类标签 |
| 31 | expect(screen.getByText('欧美流行 (15)')).toBeInTheDocument(); |
| 32 | expect(screen.getByText('华语流行 (23)')).toBeInTheDocument(); |
| 33 | |
| 34 | // 验证音乐卡片 |
| 35 | expect(screen.getByText('Blinding Lights')).toBeInTheDocument(); |
| 36 | expect(screen.getByText('Bohemian Rhapsody')).toBeInTheDocument(); |
| 37 | }); |
| 38 | }); |