Skip to content

Commit 5bfaf45

Browse files
committed
CCM-11438 Throw error
1 parent 8e157f6 commit 5bfaf45

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

frontend/src/__tests__/components/molecules/ContentRenderer.test.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,26 @@ describe('ContentRenderer', () => {
1212
expect(container).toBeEmptyDOMElement();
1313
});
1414

15-
it('throws an error for an unsupported block type', () => {
16-
const invalidContent = [
17-
{ type: 'test', value: 'invalid' },
18-
] as unknown as ContentBlock[];
15+
it('throws an error for an unsupported block type', () => {
16+
const invalidContent = [
17+
{ type: 'test', value: 'invalid' },
18+
] as unknown as ContentBlock[];
1919

20-
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
20+
const consoleErrorSpy = jest
21+
.spyOn(console, 'error')
22+
.mockImplementation(() => {});
2123

22-
expect(() => render(<ContentRenderer content={invalidContent} />))
23-
.toThrow(new Error('Unsupported content block type: test'));
24+
expect(() => render(<ContentRenderer content={invalidContent} />)).toThrow(
25+
new Error('Unsupported content block type')
26+
);
2427

25-
expect(consoleErrorSpy).toHaveBeenCalledWith(
26-
'Unsupported content block:',
27-
expect.objectContaining({ type: 'test' })
28-
);
28+
expect(consoleErrorSpy).toHaveBeenCalledWith(
29+
'Unsupported content block:',
30+
expect.objectContaining({ type: 'test' })
31+
);
2932

30-
consoleErrorSpy.mockRestore();
31-
});
33+
consoleErrorSpy.mockRestore();
34+
});
3235

3336
it('renders text blocks using MarkdownContent', () => {
3437
const content: ContentBlock[] = [

frontend/src/components/molecules/ContentRenderer/ContentRenderer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ export function ContentRenderer({ content, variables }: ContentRendererProps) {
5959
}
6060
default: {
6161
console.error('Unsupported content block:', block);
62-
throw new Error(
63-
`Unsupported content block type: ${(block as any).type}`
64-
);
62+
63+
throw new Error('Unsupported content block type');
6564
}
6665
}
6766
})}

0 commit comments

Comments
 (0)