Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Feb 24, 2021
1 parent ff64ec2 commit c0172bd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions x-pack/plugins/case/server/client/cases/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export const commentAlertMultipleIds: CommentResponseAlertsType = {
type: CommentType.alert as const,
};

export const commentGeneratedAlert: CommentResponseAlertsType = {
...commentAlertMultipleIds,
id: 'mock-comment-3',
type: CommentType.generatedAlert as const,
};

export const defaultPipes = ['informationCreated'];
export const basicParams: BasicParams = {
description: 'a description',
Expand Down
31 changes: 30 additions & 1 deletion x-pack/plugins/case/server/client/cases/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
userActions,
commentAlert,
commentAlertMultipleIds,
commentGeneratedAlert,
} from './mock';

import {
Expand Down Expand Up @@ -539,7 +540,35 @@ describe('utils', () => {
},
{
comment: 'Elastic Security Alerts attached to the case: 3',
commentId: '',
},
]);
});

it('it removes alerts correctly', async () => {
const res = await createIncident({
actionsClient: actionsMock,
theCase: {
...theCase,
comments: [
{ ...commentObj, id: 'comment-user-1' },
commentAlertMultipleIds,
commentGeneratedAlert,
],
},
userActions,
connector,
mappings,
alerts: [],
});

expect(res.comments).toEqual([
{
comment:
'Wow, good luck catching that bad meanie! (added at 2019-11-25T21:55:00.177Z by elastic)',
commentId: 'comment-user-1',
},
{
comment: 'Elastic Security Alerts attached to the case: 4',
},
]);
});
Expand Down

0 comments on commit c0172bd

Please sign in to comment.