diff --git a/String/CheckFlatCase.js b/String/CheckFlatCase.js index 709825edd1..5f8a332999 100644 --- a/String/CheckFlatCase.js +++ b/String/CheckFlatCase.js @@ -12,7 +12,7 @@ const checkFlatCase = (varname) => { // firstly, check that input is a string or not. if (typeof varname !== 'string') { - return new TypeError('Argument is not a string.') + throw new TypeError('Argument is not a string.') } const pat = /^[a-z]*$/ diff --git a/String/CheckKebabCase.js b/String/CheckKebabCase.js index 6e79ba6a5e..52d322f921 100644 --- a/String/CheckKebabCase.js +++ b/String/CheckKebabCase.js @@ -10,7 +10,7 @@ const CheckKebabCase = (varName) => { // firstly, check that input is a string or not. if (typeof varName !== 'string') { - return new TypeError('Argument is not a string.') + throw new TypeError('Argument is not a string.') } const pat = /(\w+)-(\w)([\w-]*)/ diff --git a/String/CheckPascalCase.js b/String/CheckPascalCase.js index 2e4c1ff3fa..71aaa26770 100644 --- a/String/CheckPascalCase.js +++ b/String/CheckPascalCase.js @@ -10,7 +10,7 @@ const CheckPascalCase = (VarName) => { // firstly, check that input is a string or not. if (typeof VarName !== 'string') { - return new TypeError('Argument is not a string.') + throw new TypeError('Argument is not a string.') } const pat = /^[A-Z][A-Za-z]*$/ diff --git a/String/test/CheckCamelCase.test.js b/String/test/CheckCamelCase.test.js index c1e2d83005..5875e0cd10 100644 --- a/String/test/CheckCamelCase.test.js +++ b/String/test/CheckCamelCase.test.js @@ -15,4 +15,8 @@ describe('checkCamelCase', () => { const result = checkCamelCase(value) expect(result).toBe(false) }) + + it('should throw when input is not a string', () => { + expect(() => checkCamelCase(100)).toThrowError() + }) }) diff --git a/String/test/CheckFlatCase.test.js b/String/test/CheckFlatCase.test.js index 0277f7c0e1..ccac811bf6 100644 --- a/String/test/CheckFlatCase.test.js +++ b/String/test/CheckFlatCase.test.js @@ -15,4 +15,8 @@ describe('checkFlatCase function', () => { const actual = checkFlatCase('abcdefghijklmnopqrstuvwxyz') expect(actual).toBe(true) }) + + it('should throw when input is not a string', () => { + expect(() => checkFlatCase(100)).toThrowError() + }) }) diff --git a/String/test/CheckKebabCase.test.js b/String/test/CheckKebabCase.test.js index 45bc5f2d52..239d91674e 100644 --- a/String/test/CheckKebabCase.test.js +++ b/String/test/CheckKebabCase.test.js @@ -11,3 +11,7 @@ test('CheckKebabCase(The Algorithms) -> false', () => { const res = CheckKebabCase(word) expect(res).toBeFalsy() }) + +test('CheckKebabCase throws when input is not a string', () => { + expect(() => CheckKebabCase(100)).toThrowError() +}) diff --git a/String/test/CheckPascalCase.test.js b/String/test/CheckPascalCase.test.js index 2587023f79..139b66844b 100644 --- a/String/test/CheckPascalCase.test.js +++ b/String/test/CheckPascalCase.test.js @@ -17,3 +17,7 @@ test('CheckPascalCase(The Algorithms) -> false', () => { const res = CheckPascalCase(word) expect(res).toBeFalsy() }) + +test('CheckPascalCase throws when input is not a string', () => { + expect(() => CheckPascalCase(100)).toThrowError() +})
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: