Skip to content

Commit

Permalink
chore: better namings
Browse files Browse the repository at this point in the history
  • Loading branch information
logeekal committed Aug 14, 2024
1 parent 7fdcbed commit 8a4b95b
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const getEcsDataWithRuleTypeAndTimelineTemplate = (ruleType: string, ecsData: Ec
} as Ecs;
};

const getNonEcsDataWithRuleType = (
const getNonEcsDataWithRuleTypeAndTimelineTemplate = (
ruleType: string,
nonEcsData: TimelineEventsDetailsItem[] = nonECSRowData
) => {
Expand Down Expand Up @@ -135,7 +135,7 @@ const mockTimelineTemplateResponse = {
{
and: [],
enabled: true,
id: 'event-field-default-timeline-1-host_name-0-jatins-macbook-pro_local',
id: 'some-random-id',
name: 'host.name',
excluded: false,
kqlQuery: '',
Expand Down Expand Up @@ -233,9 +233,9 @@ const RULE_TYPES_TO_BE_TESTED = [
'query',
'esql',
'eql',
'machine_learning',
/* TODO: Complete test suites for below rule types */
// 'new_terms',
// 'machine_learning',
// 'eql',
// 'threshold',
// 'threat_match',
Expand All @@ -258,7 +258,9 @@ const renderContextMenu = (items: AlertTableContextMenuItem[]) => {

describe('useInvestigateInTimeline', () => {
let mockSearchStrategyClient = {
search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType('query') })),
search: jest
.fn()
.mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate('query') })),
};
beforeEach(() => {
(getTimelineTemplate as jest.Mock).mockResolvedValue(mockTimelineTemplateResponse);
Expand All @@ -275,7 +277,7 @@ describe('useInvestigateInTimeline', () => {
afterEach(() => {
jest.clearAllMocks();
});
test('it creates a component and click handler', () => {
test('creates a component and click handler', () => {
const { result } = renderHook(() => useInvestigateInTimeline(props), {
wrapper: TestProviders,
});
Expand All @@ -300,9 +302,11 @@ describe('useInvestigateInTimeline', () => {

describe('investigate an alert with timeline template', () => {
describe.each(RULE_TYPES_TO_BE_TESTED)('Rule type : %s', (ruleType: string) => {
it('should copy columns over from template', async () => {
test('should copy columns over from template', async () => {
mockSearchStrategyClient = {
search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType(ruleType) })),
search: jest
.fn()
.mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate(ruleType) })),
};
const ecsData = getEcsDataWithRuleTypeAndTimelineTemplate(ruleType);
const { result } = renderHook(
Expand Down Expand Up @@ -345,9 +349,11 @@ describe('useInvestigateInTimeline', () => {
);
});
});
it('should copy dataProviders over from template', async () => {
test('should copy dataProviders over from template', async () => {
mockSearchStrategyClient = {
search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType(ruleType) })),
search: jest
.fn()
.mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate(ruleType) })),
};
const ecsData: Ecs = getEcsDataWithRuleTypeAndTimelineTemplate(ruleType);
const { result } = renderHook(
Expand All @@ -361,7 +367,7 @@ describe('useInvestigateInTimeline', () => {
{
and: [],
enabled: true,
id: 'event-field-default-timeline-1-host_name-0-jatins-macbook-pro_local',
id: 'some-random-id',
name: 'some host name',
excluded: false,
kqlQuery: '',
Expand Down

0 comments on commit 8a4b95b

Please sign in to comment.