fix: failing tests
This commit is contained in:
@@ -18,7 +18,7 @@ export const fetchFile = async ({
|
|||||||
onSuccess();
|
onSuccess();
|
||||||
setContent(data);
|
setContent(data);
|
||||||
})
|
})
|
||||||
.catch((e) => onError(e.response.status));
|
.catch((e) => onError(e.response?.status));
|
||||||
|
|
||||||
export const rendererHooks = ({ url, onError, onSuccess }) => {
|
export const rendererHooks = ({ url, onError, onSuccess }) => {
|
||||||
const [content, setContent] = module.state.content('');
|
const [content, setContent] = module.state.content('');
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ jest.mock('data/redux', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock('./PromptDisplay', () => ({
|
jest.mock('./PromptDisplay', () => jest.fn(({ prompt }) => (
|
||||||
SinglePromptDisplay: jest.fn(({ prompt }) => (<div data-testid="prompt-single">Prompt: {prompt}</div>)),
|
<div data-testid="prompt-display">Prompt: {prompt}</div>
|
||||||
MultiplePromptDisplay: jest.fn(({ prompt }) => (<div data-testid="prompt-multiple">Prompt: {prompt}</div>)),
|
)));
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('./SubmissionFiles', () => jest.fn(({ files }) => (
|
jest.mock('./SubmissionFiles', () => jest.fn(({ files }) => (
|
||||||
<div data-testid="submission-files">Files: {files.length}</div>
|
<div data-testid="submission-files">Files: {files.length}</div>
|
||||||
@@ -110,14 +109,12 @@ describe('ResponseDisplay', () => {
|
|||||||
|
|
||||||
it('displays single prompt when only one prompt', () => {
|
it('displays single prompt when only one prompt', () => {
|
||||||
render(<ResponseDisplay {...defaultProps} prompts={['only one prompt']} />);
|
render(<ResponseDisplay {...defaultProps} prompts={['only one prompt']} />);
|
||||||
expect(screen.queryByTestId('prompt-single')).toBeInTheDocument();
|
expect(screen.queryAllByTestId('prompt-display')).toHaveLength(1);
|
||||||
expect(screen.queryByTestId('prompt-multiple')).not.toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays multiple prompts when there are multiple prompts', () => {
|
it('displays multiple prompts when there are multiple prompts', () => {
|
||||||
render(<ResponseDisplay {...defaultProps} />);
|
render(<ResponseDisplay {...defaultProps} />);
|
||||||
expect(screen.queryByTestId('prompt-single')).not.toBeInTheDocument();
|
expect(screen.queryAllByTestId('prompt-display')).toHaveLength(2);
|
||||||
expect(screen.queryAllByTestId('prompt-multiple')).toHaveLength(2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user