From da8184a2880a6d9ff8fbb346bf430618b7e390c9 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 13 Sep 2021 20:25:04 -0400 Subject: [PATCH 1/4] update function documentation and name to match js convention --- String/CheckFlatCase.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/String/CheckFlatCase.js b/String/CheckFlatCase.js index 7e842211bd..f2ae4b6475 100644 --- a/String/CheckFlatCase.js +++ b/String/CheckFlatCase.js @@ -3,11 +3,11 @@ // Problem Source & Explanation: https://en.wikipedia.org/wiki/Naming_convention_(programming) /** - * CheckFlatCase method returns true if the string in flatcase, else return the false. - * @param {String} varname the name of the variable to check. - * @returns `Boolean` return true if the string is in flatcase, else return false. + * checkFlatCase method returns true if the string in flatcase, else return the false. + * @param {string} varname the name of the variable to check. + * @returns {boolean} return true if the string is in flatcase, else return false. */ -const CheckFlatCase = (varname) => { +const checkFlatCase = (varname) => { // firstly, check that input is a string or not. if (typeof varname !== 'string') { return new TypeError('Argument is not a string.') From e5f5223a7c7c704fa54cc162f10545c583824293 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 13 Sep 2021 20:25:41 -0400 Subject: [PATCH 2/4] add additional documentation explaining what the function does --- String/CheckFlatCase.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/String/CheckFlatCase.js b/String/CheckFlatCase.js index f2ae4b6475..b56080038e 100644 --- a/String/CheckFlatCase.js +++ b/String/CheckFlatCase.js @@ -1,4 +1,6 @@ -// CheckFlatCase method checks the given string is in flatcase or not. +// checkFlatCase method checks if the given string is in flatcase or not. Flatcase is a convention +// where all letters are in lowercase, and there are no spaces between words. +// thisvariable is an example of flatcase. In camelCase it would be thisVariable, snake_case this_variable and so on. // Problem Source & Explanation: https://en.wikipedia.org/wiki/Naming_convention_(programming) From 3dec6d64d9b89fc75fddb410b4678c01ff1ba9e3 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Mon, 13 Sep 2021 20:26:12 -0400 Subject: [PATCH 3/4] add tests for checkFlatCase function --- String/CheckFlatCase.js | 2 +- String/test/CheckFlatCase.test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 String/test/CheckFlatCase.test.js diff --git a/String/CheckFlatCase.js b/String/CheckFlatCase.js index b56080038e..709825edd1 100644 --- a/String/CheckFlatCase.js +++ b/String/CheckFlatCase.js @@ -19,4 +19,4 @@ const checkFlatCase = (varname) => { return pat.test(varname) } -module.exports = CheckFlatCase +export { checkFlatCase } diff --git a/String/test/CheckFlatCase.test.js b/String/test/CheckFlatCase.test.js new file mode 100644 index 0000000000..d2955a2cbe --- /dev/null +++ b/String/test/CheckFlatCase.test.js @@ -0,0 +1,18 @@ +import { checkFlatCase } from "../CheckFlatCase"; + +describe('checkFlatCase function', () => { + it('should return false when the input string is not in flatcase', () => { + const actual = checkFlatCase('this is not in flatcase') + expect(actual).toBe(false) + }); + + it('should return true when the input string is a single letter character', () => { + const actual = checkFlatCase('a') + expect(actual).toBe(true) + }); + + it('should return true when the input string is a string of lowercase letter characters with no spaces', () => { + const actual = checkFlatCase('abcdefghijklmnopqrstuvwxyz') + expect(actual).toBe(true) + }); +}); From 016051b8ddc8dc40a38206b7fa8c9fc78e328a53 Mon Sep 17 00:00:00 2001 From: Charlie Moore Date: Sat, 18 Sep 2021 14:38:07 -0400 Subject: [PATCH 4/4] fix standard.js errors --- String/test/CheckFlatCase.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/String/test/CheckFlatCase.test.js b/String/test/CheckFlatCase.test.js index d2955a2cbe..0277f7c0e1 100644 --- a/String/test/CheckFlatCase.test.js +++ b/String/test/CheckFlatCase.test.js @@ -1,18 +1,18 @@ -import { checkFlatCase } from "../CheckFlatCase"; +import { checkFlatCase } from '../CheckFlatCase' describe('checkFlatCase function', () => { it('should return false when the input string is not in flatcase', () => { const actual = checkFlatCase('this is not in flatcase') expect(actual).toBe(false) - }); + }) it('should return true when the input string is a single letter character', () => { const actual = checkFlatCase('a') expect(actual).toBe(true) - }); + }) it('should return true when the input string is a string of lowercase letter characters with no spaces', () => { const actual = checkFlatCase('abcdefghijklmnopqrstuvwxyz') expect(actual).toBe(true) - }); -}); + }) +})