Skip to content

Commit 3505097

Browse files
committed
CCM-11492 Update tests + coverage
1 parent cc6d37f commit 3505097

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ describe('ContentRenderer', () => {
1313
expect(container).toBeEmptyDOMElement();
1414
});
1515

16+
it('renders a plain string as MarkdownContent in inline mode', () => {
17+
render(<ContentRenderer content='Just a string block' />);
18+
expect(screen.getByText('Just a string block')).toBeInTheDocument();
19+
});
20+
1621
it('throws an error for an unsupported block type', () => {
1722
const invalidContent = [
1823
{ type: 'test', value: 'invalid' },

frontend/src/__tests__/components/organisms/MessagePlanChannelList.test.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
Channel,
77
TemplateDto,
88
} from 'nhs-notify-backend-client';
9-
import { MessagePlanTemplates } from '@app/message-plans/choose-templates/[routingConfigId]/page';
9+
import { MessagePlanTemplates } from '@utils/message-plans';
1010

1111
function buildRoutingConfig(channels: Channel[]): RoutingConfig {
1212
const now = new Date().toISOString();
@@ -91,6 +91,21 @@ describe('MessagePlanChannelList', () => {
9191
expect(container.querySelector('ul.channel-list')!.children.length).toBe(0);
9292
});
9393

94+
it('should handle cascade item without a template', () => {
95+
const messagePlan = buildRoutingConfig(['NHSAPP']);
96+
messagePlan.cascade[0].defaultTemplateId = undefined;
97+
98+
expect(() => {
99+
render(
100+
<MessagePlanChannelList
101+
messagePlan={messagePlan}
102+
templates={testTemplates}
103+
/>
104+
);
105+
}).not.toThrow();
106+
expect(screen.getByTestId('message-plan-block-NHSAPP')).toBeInTheDocument();
107+
});
108+
94109
it('should match snapshot for a digital routing plan', () => {
95110
const messagePlan = buildRoutingConfig(['NHSAPP', 'EMAIL', 'SMS']);
96111

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface ContentRendererProps {
2828

2929
export function ContentRenderer({ content, variables }: ContentRendererProps) {
3030
const items: ContentItem[] =
31-
typeof content === 'string' ? [content] : (content ?? []);
31+
typeof content === 'string' ? [content] : content;
3232
if (items.length === 0) return null;
3333

3434
return (

0 commit comments

Comments
 (0)