Skip to content

Commit

Permalink
use semantic names for functions
Browse files Browse the repository at this point in the history
refs 330731e
  • Loading branch information
ashokaditya committed Apr 29, 2021
1 parent 330731e commit 4e7dce9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { getPlaceholderText, placeholderText } from './path_placeholder';
import { getPlaceholderTextByOSType, getPlaceholderText } from './path_placeholder';
import { ConditionEntryField, OperatingSystem, TrustedAppEntryTypes } from '../endpoint/types';

const trustedAppEntry = {
Expand All @@ -16,54 +16,54 @@ const trustedAppEntry = {

describe('Trusted Apps: Path placeholder text', () => {
it('returns no placeholder text when field IS NOT PATH', () => {
expect(getPlaceholderText({ ...trustedAppEntry })).toEqual(undefined);
expect(getPlaceholderTextByOSType({ ...trustedAppEntry })).toEqual(undefined);
});

it('returns a placeholder text when field IS PATH', () => {
expect(getPlaceholderText({ ...trustedAppEntry, field: ConditionEntryField.PATH })).toEqual(
placeholderText().others.exact
);
expect(
getPlaceholderTextByOSType({ ...trustedAppEntry, field: ConditionEntryField.PATH })
).toEqual(getPlaceholderText().others.exact);
});

it('returns LINUX/MAC equivalent placholder when field IS PATH', () => {
it('returns LINUX/MAC equivalent placeholder when field IS PATH', () => {
expect(
getPlaceholderText({
getPlaceholderTextByOSType({
...trustedAppEntry,
os: OperatingSystem.MAC,
field: ConditionEntryField.PATH,
})
).toEqual(placeholderText().others.exact);
).toEqual(getPlaceholderText().others.exact);
});

it('returns LINUX/MAC equivalent placholder text when field IS PATH and WILDCARD operator is selected', () => {
it('returns LINUX/MAC equivalent placeholder text when field IS PATH and WILDCARD operator is selected', () => {
expect(
getPlaceholderText({
getPlaceholderTextByOSType({
...trustedAppEntry,
os: OperatingSystem.LINUX,
field: ConditionEntryField.PATH,
type: 'wildcard',
})
).toEqual(placeholderText().others.wildcard);
).toEqual(getPlaceholderText().others.wildcard);
});

it('returns WINDOWS equivalent placholder text when field IS PATH', () => {
it('returns WINDOWS equivalent placeholder text when field IS PATH', () => {
expect(
getPlaceholderText({
getPlaceholderTextByOSType({
...trustedAppEntry,
os: OperatingSystem.WINDOWS,
field: ConditionEntryField.PATH,
})
).toEqual(placeholderText().windows.exact);
).toEqual(getPlaceholderText().windows.exact);
});

it('returns WINDOWS equivalent placeholder text when field IS PATH and WILDCARD operator is selected', () => {
expect(
getPlaceholderText({
getPlaceholderTextByOSType({
...trustedAppEntry,
os: OperatingSystem.WINDOWS,
field: ConditionEntryField.PATH,
type: 'wildcard',
})
).toEqual(placeholderText().windows.wildcard);
).toEqual(getPlaceholderText().windows.wildcard);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ConditionEntryField, OperatingSystem, TrustedAppEntryTypes } from '../endpoint/types';

export const placeholderText = () => ({
export const getPlaceholderText = () => ({
windows: {
wildcard: 'C:\\sample\\**\\*',
exact: 'C:\\sample\\path.exe',
Expand All @@ -18,7 +18,7 @@ export const placeholderText = () => ({
},
});

export const getPlaceholderText = ({
export const getPlaceholderTextByOSType = ({
os,
field,
type,
Expand All @@ -30,14 +30,14 @@ export const getPlaceholderText = ({
if (field === ConditionEntryField.PATH) {
if (os === OperatingSystem.WINDOWS) {
if (type === 'wildcard') {
return placeholderText().windows.wildcard;
return getPlaceholderText().windows.wildcard;
}
return placeholderText().windows.exact;
return getPlaceholderText().windows.exact;
} else {
if (type === 'wildcard') {
return placeholderText().others.wildcard;
return getPlaceholderText().others.wildcard;
}
return placeholderText().others.exact;
return getPlaceholderText().others.exact;
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
OPERATOR_TITLES,
} from '../../translations';
import { useTestIdGenerator } from '../../../../../components/hooks/use_test_id_generator';
import { getPlaceholderText } from '../../../../../../../common/utils/path_placeholder';
import { getPlaceholderTextByOSType } from '../../../../../../../common/utils/path_placeholder';

const ConditionEntryCell = memo<{
showLabel: boolean;
Expand Down Expand Up @@ -193,7 +193,7 @@ export const ConditionEntryInput = memo<ConditionEntryInputProps>(
<EuiFieldText
name="value"
value={entry.value}
placeholder={getPlaceholderText({
placeholder={getPlaceholderTextByOSType({
os,
field: entry.field,
type: entry.type,
Expand Down

0 comments on commit 4e7dce9

Please sign in to comment.