Skip to content

Commit bf6171d

Browse files
committed
CCM-11492 Improve coverage
1 parent 06b1453 commit bf6171d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

frontend/src/__tests__/utils/message-plans.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
CascadeGroupName,
1414
Channel,
1515
ChannelType,
16+
Result,
1617
RoutingConfig,
1718
RoutingConfigStatus,
1819
} from 'nhs-notify-backend-client';
@@ -146,6 +147,16 @@ describe('@utils/message-plans', () => {
146147
expect.any(Object)
147148
);
148149
});
150+
151+
it('should return undefined if API returns no data', async () => {
152+
routingConfigApiMock.get.mockResolvedValueOnce(
153+
{} as Result<RoutingConfig>
154+
);
155+
156+
const response = await getMessagePlan(validRoutingConfigId);
157+
158+
expect(response).toBeUndefined();
159+
});
149160
});
150161

151162
describe('updateMessagePlan', () => {
@@ -182,6 +193,19 @@ describe('@utils/message-plans', () => {
182193
expect(loggerMock.error).not.toHaveBeenCalled();
183194
});
184195

196+
it('should return undefined if API returns no data', async () => {
197+
routingConfigApiMock.update.mockResolvedValueOnce(
198+
{} as Result<RoutingConfig>
199+
);
200+
201+
const response = await updateMessagePlan(
202+
validRoutingConfigId,
203+
baseConfig
204+
);
205+
206+
expect(response).toBeUndefined();
207+
});
208+
185209
it('should log and return undefined on API error', async () => {
186210
routingConfigApiMock.update.mockResolvedValueOnce({
187211
error: {

0 commit comments

Comments
 (0)