make placeholderText a function expression

review suggestion

elastic/kibana/pull/97623/commits/2dc4fd390cf5ea0e4fa67b3f5fc2561cbb29555e
This commit is contained in:
Ashokaditya 2021-04-29 10:51:43 +02:00
parent e8e9ce5256
commit 330731ebfc
2 changed files with 12 additions and 12 deletions

View file

@ -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);
});
});

View file

@ -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;
}
}
};