From 85f8154f0749b7ed247821886b3adb5cb63be564 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 09:28:55 -0400 Subject: [PATCH 1/5] Fix typos and update description to include a link --- Conversions/UpperCaseConversion.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Conversions/UpperCaseConversion.js b/Conversions/UpperCaseConversion.js index d3a033815..4bbd5f14f 100644 --- a/Conversions/UpperCaseConversion.js +++ b/Conversions/UpperCaseConversion.js @@ -1,26 +1,26 @@ /* - Explanation :- a user gives a String (it can be incomplete lower or - partial lower) and then the program would convert it into a - complete(all characters in upper case) upper case string. The - logic we have used in the following program is: All the lower case - characters (a-z) has ASCII value ranging from 97 to 122 and their - corresponding upper case characters (A-Z) have ASCII values 32 + Explanation :- A user gives a string (it can be incomplete lowercase or + partially in lowercase) and then the program converts it into a + completely (all characters in uppercase) uppercase string. The + logic we have used in the following program is: All the lowercase + characters (a-z) has [ASCII](https://en.wikipedia.org/wiki/ASCII) value ranging from 97 to 122 and their + corresponding uppercase characters (A-Z) have ASCII values 32 lesser than them. For example ‘a‘ has an ASCII value of 97 and ‘A‘ has an ASCII value of 65 (97 - 32). The same applies to other characters. */ /** - * UpperCaseConversion takes any case-style string and converts it to the upper case-style string. - * @param {String} inputString any case style string - * @returns {String} upper case string + * UpperCaseConversion takes any case-style string and converts it to the uppercase-style string. + * @param {string} inputString Any case style string + * @returns {string} Uppercase string */ const UpperCaseConversion = (inputString) => { // Take a string and split it into characters. const newString = inputString.split('').map(char => { // Get a character code by the use charCodeAt method. const presentCharCode = char.charCodeAt() - // If the character code lies between 97 to 122 it means they are in the lower case so convert it. + // If the character code lies between 97 to 122, it means they are in the lowercase so convert it. if (presentCharCode >= 97 && presentCharCode <= 122) { // Convert the case by use of the above explanation. return String.fromCharCode(presentCharCode - 32) From a21264698e4186ddc50004015a8c9e97de92cbb2 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 09:30:17 -0400 Subject: [PATCH 2/5] Update export for Jest testing --- Conversions/UpperCaseConversion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Conversions/UpperCaseConversion.js b/Conversions/UpperCaseConversion.js index 4bbd5f14f..34d3e0b6e 100644 --- a/Conversions/UpperCaseConversion.js +++ b/Conversions/UpperCaseConversion.js @@ -32,4 +32,4 @@ const UpperCaseConversion = (inputString) => { return newString.join('') } -module.exports = UpperCaseConversion +export { UpperCaseConversion } From a4bde8200d7111c7d3bade3d6b4930e1548411b5 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 09:30:49 -0400 Subject: [PATCH 3/5] Update capitalization style of function name to align with convention --- Conversions/UpperCaseConversion.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Conversions/UpperCaseConversion.js b/Conversions/UpperCaseConversion.js index 34d3e0b6e..fb5e810a6 100644 --- a/Conversions/UpperCaseConversion.js +++ b/Conversions/UpperCaseConversion.js @@ -11,11 +11,11 @@ */ /** - * UpperCaseConversion takes any case-style string and converts it to the uppercase-style string. + * upperCaseConversion takes any case-style string and converts it to the uppercase-style string. * @param {string} inputString Any case style string * @returns {string} Uppercase string */ -const UpperCaseConversion = (inputString) => { +const upperCaseConversion = (inputString) => { // Take a string and split it into characters. const newString = inputString.split('').map(char => { // Get a character code by the use charCodeAt method. @@ -32,4 +32,4 @@ const UpperCaseConversion = (inputString) => { return newString.join('') } -export { UpperCaseConversion } +export { upperCaseConversion } From 9aa890b17037704499f91c7c386204dcf31fce31 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 09:37:15 -0400 Subject: [PATCH 4/5] Add tests for UpperCaseConversion --- Conversions/test/UpperCaseConverstion.test.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Conversions/test/UpperCaseConverstion.test.js diff --git a/Conversions/test/UpperCaseConverstion.test.js b/Conversions/test/UpperCaseConverstion.test.js new file mode 100644 index 000000000..39b479dfb --- /dev/null +++ b/Conversions/test/UpperCaseConverstion.test.js @@ -0,0 +1,43 @@ +import { upperCaseConversion } from "../UpperCaseConversion"; + +describe(('Test the upperCaseConversion function'), () => { + it('should return an empty string when the input is an empty string', () => { + expect(upperCaseConversion('')).toEqual('') + }) + + it('should return an all-uppercase string when input is an all-uppercase string', () => { + expect(upperCaseConversion('ALLUPPERCASE')).toEqual('ALLUPPERCASE') + }) + + it('should return an all-uppercase string when input is an all-uppercase string with spaces', () => { + expect(upperCaseConversion('ALL UPPERCASE')).toEqual('ALL UPPERCASE') + }) + + it('should return an all-uppercase string when input is an all-uppercase string with punctuation', () => { + expect(upperCaseConversion('ALL UPPER-CASE!')).toEqual('ALL UPPER-CASE!') + }) + + it('should return an all-uppercase string when input is an all-lowercase string', () => { + expect(upperCaseConversion('lowercaseinput')).toEqual('LOWERCASEINPUT') + }) + + it('should return an all-uppercase string when input is an all-lowercase string with spaces', () => { + expect(upperCaseConversion('lowercase input')).toEqual('LOWERCASE INPUT') + }) + + it('should return an all-uppercase string when input is an all-lowercase string with punctuation', () => { + expect(upperCaseConversion('lower-case, input.')).toEqual('LOWER-CASE, INPUT.') + }) + + it('should return an all-uppercase string when input is an mixed-case string', () => { + expect(upperCaseConversion('mixeDCaSeINPuT')).toEqual('MIXEDCASEINPUT') + }) + + it('should return an all-uppercase string when input is an mixed-case string with spaces', () => { + expect(upperCaseConversion('mixeD CaSe INPuT')).toEqual('MIXED CASE INPUT') + }) + + it('should return an all-uppercase string when input is an mixed-case string with punctuation', () => { + expect(upperCaseConversion('mixeD-CaSe INPuT!')).toEqual('MIXED-CASE INPUT!') + }) +}) From 220e75d0466963a959813b7d41c53c3f0f256e29 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 09:44:28 -0400 Subject: [PATCH 5/5] Fix standardjs warning --- Conversions/test/UpperCaseConverstion.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Conversions/test/UpperCaseConverstion.test.js b/Conversions/test/UpperCaseConverstion.test.js index 39b479dfb..a78ec5b9c 100644 --- a/Conversions/test/UpperCaseConverstion.test.js +++ b/Conversions/test/UpperCaseConverstion.test.js @@ -1,4 +1,4 @@ -import { upperCaseConversion } from "../UpperCaseConversion"; +import { upperCaseConversion } from '../UpperCaseConversion' describe(('Test the upperCaseConversion function'), () => { it('should return an empty string when the input is an empty string', () => {