From 330731ebfcfd356707b5ff38d60106e6f1e409d9 Mon Sep 17 00:00:00 2001 From: Ashokaditya Date: Thu, 29 Apr 2021 10:51:43 +0200 Subject: [PATCH] make placeholderText a function expression review suggestion elastic/kibana/pull/97623/commits/2dc4fd390cf5ea0e4fa67b3f5fc2561cbb29555e --- .../common/utils/path_placeholder.test.ts | 12 ++++++------ .../common/utils/path_placeholder.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/security_solution/common/utils/path_placeholder.test.ts b/x-pack/plugins/security_solution/common/utils/path_placeholder.test.ts index f79a164e7d4fe..50bf0d670a109 100644 --- a/x-pack/plugins/security_solution/common/utils/path_placeholder.test.ts +++ b/x-pack/plugins/security_solution/common/utils/path_placeholder.test.ts @@ -21,7 +21,7 @@ describe('Trusted Apps: Path placeholder text', () => { it('returns a placeholder text when field IS PATH', () => { expect(getPlaceholderText({ ...trustedAppEntry, field: ConditionEntryField.PATH })).toEqual( - placeholderText.others.exact + placeholderText().others.exact ); }); @@ -32,7 +32,7 @@ describe('Trusted Apps: Path placeholder text', () => { os: OperatingSystem.MAC, field: ConditionEntryField.PATH, }) - ).toEqual(placeholderText.others.exact); + ).toEqual(placeholderText().others.exact); }); it('returns LINUX/MAC equivalent placholder text when field IS PATH and WILDCARD operator is selected', () => { @@ -43,7 +43,7 @@ describe('Trusted Apps: Path placeholder text', () => { field: ConditionEntryField.PATH, type: 'wildcard', }) - ).toEqual(placeholderText.others.wildcard); + ).toEqual(placeholderText().others.wildcard); }); it('returns WINDOWS equivalent placholder text when field IS PATH', () => { @@ -53,10 +53,10 @@ describe('Trusted Apps: Path placeholder text', () => { os: OperatingSystem.WINDOWS, field: ConditionEntryField.PATH, }) - ).toEqual(placeholderText.windows.exact); + ).toEqual(placeholderText().windows.exact); }); - it('returns WINDOWS equivalent placholder text when field IS PATH and WILDCARD operator is selected', () => { + it('returns WINDOWS equivalent placeholder text when field IS PATH and WILDCARD operator is selected', () => { expect( getPlaceholderText({ ...trustedAppEntry, @@ -64,6 +64,6 @@ describe('Trusted Apps: Path placeholder text', () => { field: ConditionEntryField.PATH, type: 'wildcard', }) - ).toEqual(placeholderText.windows.wildcard); + ).toEqual(placeholderText().windows.wildcard); }); }); diff --git a/x-pack/plugins/security_solution/common/utils/path_placeholder.ts b/x-pack/plugins/security_solution/common/utils/path_placeholder.ts index ee38ec11781d1..d87934b97908a 100644 --- a/x-pack/plugins/security_solution/common/utils/path_placeholder.ts +++ b/x-pack/plugins/security_solution/common/utils/path_placeholder.ts @@ -7,7 +7,7 @@ import { ConditionEntryField, OperatingSystem, TrustedAppEntryTypes } from '../endpoint/types'; -export const placeholderText = { +export const placeholderText = () => ({ windows: { wildcard: 'C:\\sample\\**\\*', exact: 'C:\\sample\\path.exe', @@ -16,7 +16,7 @@ export const placeholderText = { wildcard: '/opt/**/*', exact: '/opt/bin', }, -}; +}); export const getPlaceholderText = ({ os, @@ -30,14 +30,14 @@ export const getPlaceholderText = ({ if (field === ConditionEntryField.PATH) { if (os === OperatingSystem.WINDOWS) { if (type === 'wildcard') { - return placeholderText.windows.wildcard; + return placeholderText().windows.wildcard; } - return placeholderText.windows.exact; + return placeholderText().windows.exact; } else { if (type === 'wildcard') { - return placeholderText.others.wildcard; + return placeholderText().others.wildcard; } - return placeholderText.others.exact; + return placeholderText().others.exact; } } };