fix: failing tests

This commit is contained in:
Jansen Kantor
2026-01-08 15:14:48 -05:00
parent f7e6e30d99
commit 3c03358d4e
2 changed files with 6 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ export const fetchFile = async ({
onSuccess();
setContent(data);
})
.catch((e) => onError(e.response.status));
.catch((e) => onError(e.response?.status));
export const rendererHooks = ({ url, onError, onSuccess }) => {
const [content, setContent] = module.state.content('');

View File

@@ -19,10 +19,9 @@ jest.mock('data/redux', () => ({
},
}));
jest.mock('./PromptDisplay', () => ({
SinglePromptDisplay: jest.fn(({ prompt }) => (<div data-testid="prompt-single">Prompt: {prompt}</div>)),
MultiplePromptDisplay: jest.fn(({ prompt }) => (<div data-testid="prompt-multiple">Prompt: {prompt}</div>)),
}));
jest.mock('./PromptDisplay', () => jest.fn(({ prompt }) => (
<div data-testid="prompt-display">Prompt: {prompt}</div>
)));
jest.mock('./SubmissionFiles', () => jest.fn(({ files }) => (
<div data-testid="submission-files">Files: {files.length}</div>
@@ -110,14 +109,12 @@ describe('ResponseDisplay', () => {
it('displays single prompt when only one prompt', () => {
render(<ResponseDisplay {...defaultProps} prompts={['only one prompt']} />);
expect(screen.queryByTestId('prompt-single')).toBeInTheDocument();
expect(screen.queryByTestId('prompt-multiple')).not.toBeInTheDocument();
expect(screen.queryAllByTestId('prompt-display')).toHaveLength(1);
});
it('displays multiple prompts when there are multiple prompts', () => {
render(<ResponseDisplay {...defaultProps} />);
expect(screen.queryByTestId('prompt-single')).not.toBeInTheDocument();
expect(screen.queryAllByTestId('prompt-multiple')).toHaveLength(2);
expect(screen.queryAllByTestId('prompt-display')).toHaveLength(2);
});
});