From ced6c891a62064b0e787b95c28565ebacb5f9e2d Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 4 Oct 2021 12:23:05 -0400 Subject: [PATCH] Add tests for titleCaseConversion function --- Conversions/test/TitleCaseConversion.test.js | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Conversions/test/TitleCaseConversion.test.js diff --git a/Conversions/test/TitleCaseConversion.test.js b/Conversions/test/TitleCaseConversion.test.js new file mode 100644 index 000000000..a4eaa2ecd --- /dev/null +++ b/Conversions/test/TitleCaseConversion.test.js @@ -0,0 +1,51 @@ +import { titleCaseConversion } from '../TitleCaseConversion' + +describe(('Tests for the titleCaseConversion function'), () => { + it('should return an empty string when the input is an empty string', () => { + expect(titleCaseConversion('')).toEqual('') + }) + + it('should return the input string when the input string is a title case string', () => { + expect(titleCaseConversion('A Proper Title Case String')).toEqual('A Proper Title Case String') + }) + + it('should return a title case string when input is an all-uppercase string', () => { + expect(titleCaseConversion('ALL UPPER CASE')).toEqual('All Upper Case') + }) + + it('should return a title case string when input is a title case string of with spaces', () => { + expect(titleCaseConversion('ALL UPPERCASE')).toEqual('All Uppercase') + }) + + it('should return a title case string when input is a title case string of with no spaces', () => { + expect(titleCaseConversion('ALLUPPERCASE')).toEqual('Alluppercase') + }) + + it('should return a title case string when input is a title case string with punctuation', () => { + expect(titleCaseConversion('All Title Case!')).toEqual('All Title Case!') + }) + + it('should return a title case string when input is an all-lowercase string with no spaces', () => { + expect(titleCaseConversion('lowercaseinput')).toEqual('Lowercaseinput') + }) + + it('should return a title case string when input is an all-lowercase string with spaces', () => { + expect(titleCaseConversion('lowercase input')).toEqual('Lowercase Input') + }) + + it('should return a title case string when input is an all-lowercase string with punctuation', () => { + expect(titleCaseConversion('lower, case, input.')).toEqual('Lower, Case, Input.') + }) + + it('should return a title case string when input is an mixed-case string', () => { + expect(titleCaseConversion('mixeD CaSe INPuT')).toEqual('Mixed Case Input') + }) + + it('should return a title case string when input is an mixed-case string with no spaces', () => { + expect(titleCaseConversion('mixeDCaSeINPuT')).toEqual('Mixedcaseinput') + }) + + it('should return a title case string when input is an mixed-case string with punctuation', () => { + expect(titleCaseConversion('mixeD, CaSe, INPuT!')).toEqual('Mixed, Case, Input!') + }) +})