chore: Auto capitalize the name field while sending the canned response/variables (#6758)

* capitalize name before sending the message

* Fix specs

* Code cleanups
This commit is contained in:
Muhsin Keloth
2023-03-27 18:49:48 +05:30
committed by GitHub
parent b3850cb4fa
commit 5b7bed9640
7 changed files with 46 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import {
getLastName,
getMessageVariables,
getUndefinedVariablesInMessage,
capitalizeName,
} from '../messageHelper';
const variables = {
@@ -136,3 +137,18 @@ describe('#getUndefinedVariablesInMessage', () => {
);
});
});
describe('#capitalizeName', () => {
it('Capitalize name if name is passed', () => {
const string = 'hello world';
expect(capitalizeName(string)).toBe('Hello world');
});
it('returns empty string if the string is empty', () => {
const string = '';
expect(capitalizeName(string)).toBe('');
});
it('Capitalize first name if full name is passed', () => {
const string = 'john Doe';
expect(capitalizeName(string)).toBe('John Doe');
});
});