Skip to content

Commit

Permalink
make placeholderText a function expression
Browse files Browse the repository at this point in the history
review suggestion

/pull/97623/commits/2dc4fd390cf5ea0e4fa67b3f5fc2561cbb29555e
  • Loading branch information
ashokaditya committed Apr 29, 2021
1 parent e8e9ce5 commit 330731e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});

Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -53,17 +53,17 @@ 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,
os: OperatingSystem.WINDOWS,
field: ConditionEntryField.PATH,
type: 'wildcard',
})
).toEqual(placeholderText.windows.wildcard);
).toEqual(placeholderText().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 placeholderText = () => ({
windows: {
wildcard: 'C:\\sample\\**\\*',
exact: 'C:\\sample\\path.exe',
Expand All @@ -16,7 +16,7 @@ export const placeholderText = {
wildcard: '/opt/**/*',
exact: '/opt/bin',
},
};
});

export const getPlaceholderText = ({
os,
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 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;
}
}
};

0 comments on commit 330731e

Please sign in to comment.