|
1 | 1 | import React from 'react' |
2 | 2 | import { render, screen, fireEvent, waitFor } from '@testing-library/react' |
| 3 | +import { act } from 'react' |
3 | 4 | import '@testing-library/jest-dom' |
4 | 5 | import SectionCard from './SectionCard' |
5 | 6 | import { AppStateContext } from '../../state/AppProvider' |
6 | 7 | import { sectionGenerate } from '../../api' |
7 | 8 | import { MemoryRouter } from 'react-router-dom' |
8 | 9 |
|
9 | 10 | import { ChatHistoryLoadingState } from '../../api/models' |
10 | | -import { act } from 'react-dom/test-utils' |
11 | 11 |
|
12 | 12 | import {defaultMockState} from '../../test/test.utils'; |
13 | 13 |
|
@@ -77,17 +77,27 @@ describe('SectionCard Component', () => { |
77 | 77 | }) |
78 | 78 |
|
79 | 79 | it('When context not available throws an error', async () => { |
| 80 | + // Suppress console.error for this test to avoid cluttering test output |
| 81 | + const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}) |
| 82 | + |
80 | 83 | expect(() => |
81 | 84 | render( |
82 | 85 | <MemoryRouter> |
83 | 86 | <SectionCard sectionIdx={0} /> |
84 | 87 | </MemoryRouter> |
85 | 88 | ) |
86 | 89 | ).toThrow('useAppState must be used within a AppStateProvider') |
| 90 | + |
| 91 | + consoleSpy.mockRestore() |
87 | 92 | }) |
88 | 93 |
|
89 | 94 | it('When no section available in context throws an error', async () => { |
| 95 | + // Suppress console.error for this test to avoid cluttering test output |
| 96 | + const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}) |
| 97 | + |
90 | 98 | expect(() => renderWithContext(2)).toThrow('Section not found') |
| 99 | + |
| 100 | + consoleSpy.mockRestore() |
91 | 101 | }) |
92 | 102 |
|
93 | 103 | it('renders section title and description', async () => { |
|
0 commit comments