Skip to content

Commit

Permalink
sync up with main
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Jan 23, 2023
1 parent be98c99 commit cc33844
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { renderHook } from '@testing-library/react-hooks';
import { wrapper } from '../../../mocks';

import { useLensAttributes } from '../../../use_lens_attributes';

import { getRiskScoreOverTimeAreaAttributes } from './risk_score_over_time_area';

jest.mock('../../../../../containers/sourcerer', () => ({
useSourcererDataView: jest.fn().mockReturnValue({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
}),
}));

jest.mock('../../../../../utils/route/use_route_spy', () => ({
useRouteSpy: jest.fn().mockReturnValue([
{
detailName: 'mockHost',
pageName: 'hosts',
tabName: 'hostRisk',
},
]),
}));

jest.mock('uuid', () => ({
v4: jest
.fn()
.mockReturnValueOnce('d594baeb-5eca-480c-8885-ba79eaf41372')
.mockReturnValue('1dd5663b-f062-43f8-8688-fc8166c2ca8e'),
}));

describe('getRiskScoreOverTimeAreaAttributes', () => {
it('should render', () => {
const { result } = renderHook(
() =>
useLensAttributes({
getLensAttributes: getRiskScoreOverTimeAreaAttributes,
stackByField: 'host',
extraOptions: {
spaceId: 'mockSpaceId',
},
}),
{ wrapper }
);

expect(result?.current).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* 2.0.
*/

import uuid from 'uuid';
import { v4 as uuidv4 } from 'uuid';
import type { GetLensAttributes } from '../../../types';
export const getRiskScoreOverTimeAreaAttributes: GetLensAttributes = (
stackByField,
extraOptions = { spaceId: 'default' }
) => {
const layerId = uuid.v4();
const internalReferenceId = uuid.v4();
const layerId = uuidv4();
const internalReferenceId = uuidv4();
return {
title: `${stackByField} risk score over time`,
description: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { isUserRiskScore } from '../../../../../common/search_strategy';
import { useSpaceId } from '../../../../common/hooks/use_space_id';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { VisualizationEmbeddable } from '../../../../common/components/visualization_actions/visualization_embeddable';
import { getRiskScoreOverTimeAreaAttributes } from '../../../../common/components/visualization_actions/lens_attributes/common/risk_scores/risk_score_overtime_area';
import { getRiskScoreOverTimeAreaAttributes } from '../../../../common/components/visualization_actions/lens_attributes/common/risk_scores/risk_score_over_time_area';

export interface RiskScoreOverTimeProps {
from: string;
Expand Down

0 comments on commit cc33844

Please sign in to comment.