7338 refactor actionbar and contextmenu to use the context store (#7462)
Closes #7338
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
import { turnIntoEmptyStringIfWhitespacesOnly } from '../turnIntoEmptyStringIfWhitespacesOnly';
|
||||
|
||||
describe('turnIntoEmptyStringIfWhitespacesOnly', () => {
|
||||
it('should return an empty string for whitespace-only input', () => {
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly(' ')).toBe('');
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly('\t\n ')).toBe('');
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly(' \n\r\t')).toBe('');
|
||||
});
|
||||
|
||||
it('should return the original string for non-whitespace input', () => {
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly('hello')).toBe('hello');
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly(' hello ')).toBe(' hello ');
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly('123')).toBe('123');
|
||||
});
|
||||
|
||||
it('should handle empty string input', () => {
|
||||
expect(turnIntoEmptyStringIfWhitespacesOnly('')).toBe('');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,19 @@
|
||||
import { turnIntoUndefinedIfWhitespacesOnly } from '../turnIntoUndefinedIfWhitespacesOnly';
|
||||
|
||||
describe('turnIntoUndefinedIfWhitespacesOnly', () => {
|
||||
it('should return undefined for whitespace-only input', () => {
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly(' ')).toBeUndefined();
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly('\t\n ')).toBeUndefined();
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly(' \n\r\t')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return the original string for non-whitespace input', () => {
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly('hello')).toBe('hello');
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly(' hello ')).toBe(' hello ');
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly('123')).toBe('123');
|
||||
});
|
||||
|
||||
it('should handle empty string input', () => {
|
||||
expect(turnIntoUndefinedIfWhitespacesOnly('')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@ -1,5 +1,5 @@
|
||||
export const turnIntoUndefinedIfWhitespacesOnly = (
|
||||
value: string,
|
||||
): string | undefined => {
|
||||
return value.trim() === '' ? undefined : value.trim();
|
||||
return value.trim() === '' ? undefined : value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user