From e53c31f79ab88284d78b0fb24a3d05f8bdfa23f7 Mon Sep 17 00:00:00 2001 From: CAWilson94 Date: Tue, 5 Nov 2024 15:20:01 +0000 Subject: [PATCH] jest test to test riskscore returns formatted value when value applied, or does not render when no value applied --- .../body/renderers/formatted_field.test.tsx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.test.tsx index 868848acd12be..a5173e44f2524 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/formatted_field.test.tsx @@ -15,6 +15,7 @@ import { useMountAppended } from '../../../../../common/utils/use_mount_appended import { FormattedFieldValue } from './formatted_field'; import { HOST_NAME_FIELD_NAME } from './constants'; +import { formatRiskScore } from '../../../../../entity_analytics/common'; jest.mock('@elastic/eui', () => { const original = jest.requireActual('@elastic/eui'); @@ -285,4 +286,39 @@ describe('Events', () => { ); expect(wrapper.text()).toEqual(getEmptyValue()); }); + + test('it renders the formatted risk score when fieldName is RISK_SCORE and value is provided', () => { + const riskScoreValue = 85; + const wrapper = mount( + + + + ); + + expect( + wrapper.find(`[data-test-subj="formatted-field-kibana.alert.risk_score"]`).text() + ).toEqual(formatRiskScore(riskScoreValue)); + }); + + test('it does not render anything when fieldName is RISK_SCORE and value is not provided', () => { + const wrapper = mount( + + + + ); + + expect( + wrapper.find(`[data-test-subj="formatted-field-kibana.alert.risk_score"]`).exists() + ).toEqual(false); + }); });