From f02636487418539b68b3e5fc28dc1dc35cde9c35 Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 10:53:06 +0100 Subject: [PATCH 1/8] created max and min helper functions --- src/helperise/max_min_helpers/o_kere_julo.js | 0 src/helperise/max_min_helpers/o_tobi_julo.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/helperise/max_min_helpers/o_kere_julo.js create mode 100644 src/helperise/max_min_helpers/o_tobi_julo.js diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js new file mode 100644 index 0000000..e69de29 diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js new file mode 100644 index 0000000..e69de29 From 610bd46a276686c20aec82ebee785268cedc6a7a Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 10:54:56 +0100 Subject: [PATCH 2/8] created max and min helper functions --- src/helperise/max_min_helpers/o_kere_julo.js | 24 +++++++++++++++++++ src/helperise/max_min_helpers/o_tobi_julo.js | 25 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js index e69de29..ff61fbe 100644 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ b/src/helperise/max_min_helpers/o_kere_julo.js @@ -0,0 +1,24 @@ +/** + * Get the minimum oflist of numbers + * input can either be an array or a number of arguments seperated by a ',' + * + * note that if the first argument is an array, all other arguments are neglected + * @returns {[number]} minimumNumber + */ +function o_kere_julo(){ + var obj = arguments[0] + var array = [] + if(isArray(obj)){ + array = obj + }else{ + for (var i=0; i < arguments.length; i++) { + array.push(arguments[i]) + } + } + return Math.min(...array); +} +function isArray(obj){ + return !!obj && obj.constructor === Array; +} + +module.exports = o_kere_julo; \ No newline at end of file diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js index e69de29..019a107 100644 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ b/src/helperise/max_min_helpers/o_tobi_julo.js @@ -0,0 +1,25 @@ +/** + * Get the maximum of list of numbers, + * input can either be an array or a number of arguments seperated by a ',' + * + * note that if the first argument is an array, all other arguments are neglected + * @returns {[number]} maximumNumber + */ +function o_tobi_julo(){ + var obj = arguments[0] + var array = [] + if(isArray(obj)){ + array = obj + }else{ + for (var i=0; i < arguments.length; i++) { + array.push(arguments[i]) + + } + } + return Math.max(...array); +} +function isArray(obj){ + return !!obj && obj.constructor === Array; +} + +module.exports = o_tobi_julo; \ No newline at end of file From aef75c9e306ab1e76866deeb00a93b36fb7522ca Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 11:45:57 +0100 Subject: [PATCH 3/8] created max and min helper functions --- src/helperise/max_min_helpers/o_kere_julo.js | 21 ++++++++++---------- src/helperise/max_min_helpers/o_tobi_julo.js | 21 ++++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js index ff61fbe..a0c6911 100644 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ b/src/helperise/max_min_helpers/o_kere_julo.js @@ -1,24 +1,23 @@ /** * Get the minimum oflist of numbers * input can either be an array or a number of arguments seperated by a ',' - * * note that if the first argument is an array, all other arguments are neglected * @returns {[number]} minimumNumber */ -function o_kere_julo(){ - var obj = arguments[0] - var array = [] - if(isArray(obj)){ - array = obj - }else{ - for (var i=0; i < arguments.length; i++) { - array.push(arguments[i]) +function oKereJulo () { + var obj = arguments[0]; + var array = []; + if (isArray(obj)) { + array = obj; + } else { + for ( var i=0; i < arguments.length; i++ ) { + array.push(arguments[i]); } } return Math.min(...array); } -function isArray(obj){ +function isArray (obj) { return !!obj && obj.constructor === Array; } -module.exports = o_kere_julo; \ No newline at end of file +module.exports = o_kere_julo; diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js index 019a107..29bf8d8 100644 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ b/src/helperise/max_min_helpers/o_tobi_julo.js @@ -1,25 +1,24 @@ /** * Get the maximum of list of numbers, * input can either be an array or a number of arguments seperated by a ',' - * * note that if the first argument is an array, all other arguments are neglected * @returns {[number]} maximumNumber */ -function o_tobi_julo(){ - var obj = arguments[0] - var array = [] - if(isArray(obj)){ - array = obj - }else{ - for (var i=0; i < arguments.length; i++) { - array.push(arguments[i]) +function oTobiJulo () { + var obj = arguments[0]; + var array = []; + if (isArray(obj)) { + array = obj; + } else { + for ( var i=0; i < arguments.length; i++ ) { + array.push(arguments[i]); } } return Math.max(...array); } -function isArray(obj){ +function isArray (obj) { return !!obj && obj.constructor === Array; } -module.exports = o_tobi_julo; \ No newline at end of file +module.exports = o_tobi_julo; From 912edda6bb1d74e3b231519b93d14078d8a7800f Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 12:17:40 +0100 Subject: [PATCH 4/8] created max and min helper functions --- src/helperise/max_min_helpers/o_kere_julo.js | 4 ++-- src/helperise/max_min_helpers/o_tobi_julo.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js index a0c6911..5681474 100644 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ b/src/helperise/max_min_helpers/o_kere_julo.js @@ -10,7 +10,7 @@ function oKereJulo () { if (isArray(obj)) { array = obj; } else { - for ( var i=0; i < arguments.length; i++ ) { + for (var i = 0; i < arguments.length; i++) { array.push(arguments[i]); } } @@ -20,4 +20,4 @@ function isArray (obj) { return !!obj && obj.constructor === Array; } -module.exports = o_kere_julo; +module.exports = oKereJulo; diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js index 29bf8d8..fca2dc7 100644 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ b/src/helperise/max_min_helpers/o_tobi_julo.js @@ -10,9 +10,8 @@ function oTobiJulo () { if (isArray(obj)) { array = obj; } else { - for ( var i=0; i < arguments.length; i++ ) { + for (var i = 0; i < arguments.length; i++) { array.push(arguments[i]); - } } return Math.max(...array); @@ -21,4 +20,4 @@ function isArray (obj) { return !!obj && obj.constructor === Array; } -module.exports = o_tobi_julo; +module.exports = oTobiJulo; From b22bf51184db0e2d3aa91ff2b33e92ca659adf81 Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 18:17:06 +0100 Subject: [PATCH 5/8] created test cases for max and min --- sample/maxmin.yl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sample/maxmin.yl diff --git a/sample/maxmin.yl b/sample/maxmin.yl new file mode 100644 index 0000000..955d9c2 --- /dev/null +++ b/sample/maxmin.yl @@ -0,0 +1,19 @@ +sope "eleyi a fun wa ni nomba to tobi julo"; +sope ""; +jeki maxNumber = oTobiJulo(3,6,87,2,32,33); +sope maxNumber; + +sope "eleyi a fun wa ni nomba to kere julo"; +sope ""; +jeki minNumber = oKereJulo(3,6,87,2,32,33); +sope minNumber; + +sope "eleyi a fun wa ni nomba to tobi julo"; +sope ""; +jeki maximum = oTobiJulo([3,6,87,2,32,33]); +sope maximum; + +sope "eleyi a fun wa ni nomba to kere julo"; +sope ""; +jeki minimum = oKereJulo([3,6,87,2,32,33],23,22,232); +sope minimum; \ No newline at end of file From a7bab5726503a8a1d0d09d556c23ac43e265e8a7 Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 19 Dec 2018 19:57:19 +0100 Subject: [PATCH 6/8] created test cases for max and min --- src/helperise/max_min_helpers/o_kere_julo.js | 5 ++++- src/helperise/max_min_helpers/o_tobi_julo.js | 5 ++++- .../helperise/max_min_helpers/o_kere_julo.js | 18 ++++++++++++++++++ .../helperise/max_min_helpers/o_tobi_julo.js | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/tests/helperise/max_min_helpers/o_kere_julo.js create mode 100644 src/tests/helperise/max_min_helpers/o_tobi_julo.js diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js index 5681474..25b1da8 100644 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ b/src/helperise/max_min_helpers/o_kere_julo.js @@ -11,7 +11,10 @@ function oKereJulo () { array = obj; } else { for (var i = 0; i < arguments.length; i++) { - array.push(arguments[i]); + if (isNaN(arguments[i])) { + } else { + array.push(arguments[i]); + } } } return Math.min(...array); diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js index fca2dc7..ef378bf 100644 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ b/src/helperise/max_min_helpers/o_tobi_julo.js @@ -11,7 +11,10 @@ function oTobiJulo () { array = obj; } else { for (var i = 0; i < arguments.length; i++) { - array.push(arguments[i]); + if (isNaN(arguments[i])) { + } else { + array.push(arguments[i]); + } } } return Math.max(...array); diff --git a/src/tests/helperise/max_min_helpers/o_kere_julo.js b/src/tests/helperise/max_min_helpers/o_kere_julo.js new file mode 100644 index 0000000..d363984 --- /dev/null +++ b/src/tests/helperise/max_min_helpers/o_kere_julo.js @@ -0,0 +1,18 @@ +const oKereJulo = require("../../../helperise/max_min_helpers/o_kere_julo.js"); + +describe("OkereJulo Test suite", () => { + test("It should return minimum numnber in the array", () => { + const array = [34,44,455,54, ]; + expect(oKereJulo(array)).toBe(34); + }); + + test("It should return minimum numnber in the array", () => { + const array = ['34','44','455','54', ]; + expect(() => oKereJulo(array)).toBe(34); + }); + + test("It should fail because helper function OkereJulo accepts only an array of numbers as argument", () => { + const array = ['34','44','455','54','fsfghfsf' ]; + expect(() => oKereJulo(array)).toThrow("element of array must be a number"); + }); +}); diff --git a/src/tests/helperise/max_min_helpers/o_tobi_julo.js b/src/tests/helperise/max_min_helpers/o_tobi_julo.js new file mode 100644 index 0000000..0d4c1f4 --- /dev/null +++ b/src/tests/helperise/max_min_helpers/o_tobi_julo.js @@ -0,0 +1,18 @@ +const oTobiJulo = require("../../../helperise/max_min_helpers/o_tobi_julo.js"); + +describe("OtobiJulo Test suite", () => { + test("It should return maximum numnber in the array", () => { + const array = [34,44,455,54, ]; + expect(oTobiJulo(array)).toBe(455); + }); + + test("It should return maximum numnber in the array", () => { + const array = ['34','44','455','54', ]; + expect(() => oTobiJulo(array)).toBe(455); + }); + + test("It should fail because helper function oTobiJulo accepts only an array of numbers as argument", () => { + const array = ['34','44','455','54','fsfghfsf', ]; + expect(() => oTobiJulo(array)).toThrow("element of array must be a number"); + }); +}); From 161e7d9e84795c9f7dd479beec4bfca20cbbfab6 Mon Sep 17 00:00:00 2001 From: Harjacober Date: Wed, 2 Jan 2019 10:43:06 +0100 Subject: [PATCH 7/8] optimized helperise function --- sample/maxmin.yl | 19 ------------------- src/helperise/max_min_helpers/o_kere_julo.js | 20 +++++++++++--------- src/helperise/max_min_helpers/o_tobi_julo.js | 20 +++++++++++--------- 3 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 sample/maxmin.yl diff --git a/sample/maxmin.yl b/sample/maxmin.yl deleted file mode 100644 index 955d9c2..0000000 --- a/sample/maxmin.yl +++ /dev/null @@ -1,19 +0,0 @@ -sope "eleyi a fun wa ni nomba to tobi julo"; -sope ""; -jeki maxNumber = oTobiJulo(3,6,87,2,32,33); -sope maxNumber; - -sope "eleyi a fun wa ni nomba to kere julo"; -sope ""; -jeki minNumber = oKereJulo(3,6,87,2,32,33); -sope minNumber; - -sope "eleyi a fun wa ni nomba to tobi julo"; -sope ""; -jeki maximum = oTobiJulo([3,6,87,2,32,33]); -sope maximum; - -sope "eleyi a fun wa ni nomba to kere julo"; -sope ""; -jeki minimum = oKereJulo([3,6,87,2,32,33],23,22,232); -sope minimum; \ No newline at end of file diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js index 25b1da8..acbff21 100644 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ b/src/helperise/max_min_helpers/o_kere_julo.js @@ -4,10 +4,10 @@ * note that if the first argument is an array, all other arguments are neglected * @returns {[number]} minimumNumber */ -function oKereJulo () { - var obj = arguments[0]; - var array = []; - if (isArray(obj)) { +function eyiToKereJu () { + const obj = arguments[0]; + let array = []; + if (Array.isArray(obj)) { array = obj; } else { for (var i = 0; i < arguments.length; i++) { @@ -17,10 +17,12 @@ function oKereJulo () { } } } - return Math.min(...array); -} -function isArray (obj) { - return !!obj && obj.constructor === Array; + const minValue = Math.min(...array); + if (isNaN(minValue)) { + throw new Error("Invalid param given to helper ise eyiToKereJu."); + } else { + return minValue; + } } -module.exports = oKereJulo; +module.exports = eyiToKereJu; diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js index ef378bf..89deac3 100644 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ b/src/helperise/max_min_helpers/o_tobi_julo.js @@ -4,10 +4,10 @@ * note that if the first argument is an array, all other arguments are neglected * @returns {[number]} maximumNumber */ -function oTobiJulo () { - var obj = arguments[0]; - var array = []; - if (isArray(obj)) { +function eyiToTobiJu () { + const obj = arguments[0]; + let array = []; + if (Array.isArray(obj)) { array = obj; } else { for (var i = 0; i < arguments.length; i++) { @@ -17,10 +17,12 @@ function oTobiJulo () { } } } - return Math.max(...array); -} -function isArray (obj) { - return !!obj && obj.constructor === Array; + const maxValue = Math.max(...array); + if (isNaN(maxValue)) { + throw new Error("Invalid param given to helper ise eyiToTobiJu."); + } else { + return maxValue; + } } -module.exports = oTobiJulo; +module.exports = eyiToTobiJu; From 15221f3e90b521afba4bc7b7e74ca9dcd0e192d4 Mon Sep 17 00:00:00 2001 From: Harjacober Date: Thu, 3 Jan 2019 22:43:43 +0100 Subject: [PATCH 8/8] optimized and registered max_min_helpers functions --- .../max_min_helpers/eyi_to_kere_ju.js | 17 +++++++++++ .../max_min_helpers/eyi_to_tobi_ju.js | 17 +++++++++++ src/helperise/max_min_helpers/o_kere_julo.js | 28 ------------------- src/helperise/max_min_helpers/o_tobi_julo.js | 28 ------------------- src/helperise/registeredHelperIse.js | 2 ++ .../max_min_helpers/eyi_to_kere_ju.js | 28 +++++++++++++++++++ .../max_min_helpers/eyi_to_tobi_ju.js | 28 +++++++++++++++++++ .../helperise/max_min_helpers/o_kere_julo.js | 18 ------------ .../helperise/max_min_helpers/o_tobi_julo.js | 18 ------------ 9 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 src/helperise/max_min_helpers/eyi_to_kere_ju.js create mode 100644 src/helperise/max_min_helpers/eyi_to_tobi_ju.js delete mode 100644 src/helperise/max_min_helpers/o_kere_julo.js delete mode 100644 src/helperise/max_min_helpers/o_tobi_julo.js create mode 100644 src/tests/helperise/max_min_helpers/eyi_to_kere_ju.js create mode 100644 src/tests/helperise/max_min_helpers/eyi_to_tobi_ju.js delete mode 100644 src/tests/helperise/max_min_helpers/o_kere_julo.js delete mode 100644 src/tests/helperise/max_min_helpers/o_tobi_julo.js diff --git a/src/helperise/max_min_helpers/eyi_to_kere_ju.js b/src/helperise/max_min_helpers/eyi_to_kere_ju.js new file mode 100644 index 0000000..a9b2f21 --- /dev/null +++ b/src/helperise/max_min_helpers/eyi_to_kere_ju.js @@ -0,0 +1,17 @@ +/** + * Get the minimum oflist of numbers + * input can either be an array or a number of arguments seperated by a ',' + * note that if the first argument is an array, all other arguments are neglected + * @returns {[number]} minimumNumber + */ +function eyiToKereJu (args) { + if (Array.isArray(args)) { + if (Array.isArray(args[0])) args = args[0]; + const min = Math.min(...args); + if (Number.isNaN(min)) throw new Error("Invalid number params passed to eyiToKereJu"); + return min; + } + throw new Error("Yorlang System Error: args should be an array"); +} + +module.exports = eyiToKereJu; diff --git a/src/helperise/max_min_helpers/eyi_to_tobi_ju.js b/src/helperise/max_min_helpers/eyi_to_tobi_ju.js new file mode 100644 index 0000000..abc2cd7 --- /dev/null +++ b/src/helperise/max_min_helpers/eyi_to_tobi_ju.js @@ -0,0 +1,17 @@ +/** + * Get the maximum of list of numbers, + * input can either be an array or a number of arguments seperated by a ',' + * note that if the first argument is an array, all other arguments are neglected + * @returns {[number]} maximumNumber + */ +function eyiToTobiJu (args) { + if (Array.isArray(args)) { + if (Array.isArray(args[0])) args = args[0]; + const max = Math.max(...args); + if (Number.isNaN(max)) throw new Error("Invalid number params passed to eyiToTobiJu"); + return max; + } + throw new Error("Yorlang System Error: args should be an array"); +} + +module.exports = eyiToTobiJu; diff --git a/src/helperise/max_min_helpers/o_kere_julo.js b/src/helperise/max_min_helpers/o_kere_julo.js deleted file mode 100644 index acbff21..0000000 --- a/src/helperise/max_min_helpers/o_kere_julo.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Get the minimum oflist of numbers - * input can either be an array or a number of arguments seperated by a ',' - * note that if the first argument is an array, all other arguments are neglected - * @returns {[number]} minimumNumber - */ -function eyiToKereJu () { - const obj = arguments[0]; - let array = []; - if (Array.isArray(obj)) { - array = obj; - } else { - for (var i = 0; i < arguments.length; i++) { - if (isNaN(arguments[i])) { - } else { - array.push(arguments[i]); - } - } - } - const minValue = Math.min(...array); - if (isNaN(minValue)) { - throw new Error("Invalid param given to helper ise eyiToKereJu."); - } else { - return minValue; - } -} - -module.exports = eyiToKereJu; diff --git a/src/helperise/max_min_helpers/o_tobi_julo.js b/src/helperise/max_min_helpers/o_tobi_julo.js deleted file mode 100644 index 89deac3..0000000 --- a/src/helperise/max_min_helpers/o_tobi_julo.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Get the maximum of list of numbers, - * input can either be an array or a number of arguments seperated by a ',' - * note that if the first argument is an array, all other arguments are neglected - * @returns {[number]} maximumNumber - */ -function eyiToTobiJu () { - const obj = arguments[0]; - let array = []; - if (Array.isArray(obj)) { - array = obj; - } else { - for (var i = 0; i < arguments.length; i++) { - if (isNaN(arguments[i])) { - } else { - array.push(arguments[i]); - } - } - } - const maxValue = Math.max(...array); - if (isNaN(maxValue)) { - throw new Error("Invalid param given to helper ise eyiToTobiJu."); - } else { - return maxValue; - } -} - -module.exports = eyiToTobiJu; diff --git a/src/helperise/registeredHelperIse.js b/src/helperise/registeredHelperIse.js index 4893b58..cc23c10 100644 --- a/src/helperise/registeredHelperIse.js +++ b/src/helperise/registeredHelperIse.js @@ -4,5 +4,7 @@ helperIseDeclarations["siLetaNla"] = require("./string_helpers/si_leta_nla.js"); helperIseDeclarations["siLetaKekere"] = require("./string_helpers/si_leta_kekere.js"); helperIseDeclarations["teSibi"] = require("./input_output/tesibi.js"); helperIseDeclarations["aago"] = require("./datetime_helpers/aago.js"); +helperIseDeclarations["eyiToKereJu"] = require("./max_min_helpers/eyi_to_kere_ju.js"); +helperIseDeclarations["eyiToTobiJu"] = require("./max_min_helpers/eyi_to_tobi_ju.js"); module.exports = helperIseDeclarations; diff --git a/src/tests/helperise/max_min_helpers/eyi_to_kere_ju.js b/src/tests/helperise/max_min_helpers/eyi_to_kere_ju.js new file mode 100644 index 0000000..d138707 --- /dev/null +++ b/src/tests/helperise/max_min_helpers/eyi_to_kere_ju.js @@ -0,0 +1,28 @@ +const oKereJulo = require("../../../helperise/max_min_helpers/eyi_to_kere_ju.js"); + +describe("eyiToKereJu Test suite", () => { + test("It should return minimum numnber in the array", () => { + const array = [34,44,455,54, ]; + expect(eyiToKereJu(array)).toBe(34); + }); + + test("It should return minimum numnber in the array", () => { + const array = ['34','44','455','54', ]; + expect(() => eyiToKereJu(array)).toBe(34); + }); + + test("It should fail because helper function OkereJulo accepts only an array of numbers as argument", () => { + const array = ['34','44','455','54','fsfghfsf' ]; + expect(() => eyiToKereJu(array)).toThrow("element of array must be a number"); + }); + + test("It should ignore other arguments and return minimum number in the array which is the first argument", () => { + const array = [[34,44,455],54,'fsfghfsf' ]; + expect(() => eyiToKereJu(array)).toBe(34); + }); + + test("It should fail because helper function eyiToKereJu expects an array as argument", () => { + const array = 8; + expect(() => eyiToKereJu(array)).toThrow("Yorlang system error"); + }); +}); diff --git a/src/tests/helperise/max_min_helpers/eyi_to_tobi_ju.js b/src/tests/helperise/max_min_helpers/eyi_to_tobi_ju.js new file mode 100644 index 0000000..b291dd5 --- /dev/null +++ b/src/tests/helperise/max_min_helpers/eyi_to_tobi_ju.js @@ -0,0 +1,28 @@ +const oTobiJulo = require("../../../helperise/max_min_helpers/eyi_to_tobi_ju.js"); + +describe("eyiToTobiJu Test suite", () => { + test("It should return maximum numnber in the array", () => { + const array = [34,44,455,54, ]; + expect(eyiToTobiJu(array)).toBe(455); + }); + + test("It should return maximum numnber in the array", () => { + const array = ['34','44','455','54', ]; + expect(() => eyiToTobiJu(array)).toBe(455); + }); + + test("It should fail because helper function oTobiJulo accepts only an array of numbers as argument", () => { + const array = ['34','44','455','54','fsfghfsf', ]; + expect(() => eyiToTobiJu(array)).toThrow("element of array must be a number"); + }); + + test("It should ignore other arguments and return maximum number in the array which is the first argument", () => { + const array = [[34,44,455],54,'fsfghfsf' ]; + expect(() => eyiToTobiJu(array)).toBe(455); + }); + + test("It should fail because helper function eyiToTobiJu expects an array as argument", () => { + const array = 8; + expect(() => eyiToTobiJu(array)).toThrow("Yorlang system error"); + }); +}); diff --git a/src/tests/helperise/max_min_helpers/o_kere_julo.js b/src/tests/helperise/max_min_helpers/o_kere_julo.js deleted file mode 100644 index d363984..0000000 --- a/src/tests/helperise/max_min_helpers/o_kere_julo.js +++ /dev/null @@ -1,18 +0,0 @@ -const oKereJulo = require("../../../helperise/max_min_helpers/o_kere_julo.js"); - -describe("OkereJulo Test suite", () => { - test("It should return minimum numnber in the array", () => { - const array = [34,44,455,54, ]; - expect(oKereJulo(array)).toBe(34); - }); - - test("It should return minimum numnber in the array", () => { - const array = ['34','44','455','54', ]; - expect(() => oKereJulo(array)).toBe(34); - }); - - test("It should fail because helper function OkereJulo accepts only an array of numbers as argument", () => { - const array = ['34','44','455','54','fsfghfsf' ]; - expect(() => oKereJulo(array)).toThrow("element of array must be a number"); - }); -}); diff --git a/src/tests/helperise/max_min_helpers/o_tobi_julo.js b/src/tests/helperise/max_min_helpers/o_tobi_julo.js deleted file mode 100644 index 0d4c1f4..0000000 --- a/src/tests/helperise/max_min_helpers/o_tobi_julo.js +++ /dev/null @@ -1,18 +0,0 @@ -const oTobiJulo = require("../../../helperise/max_min_helpers/o_tobi_julo.js"); - -describe("OtobiJulo Test suite", () => { - test("It should return maximum numnber in the array", () => { - const array = [34,44,455,54, ]; - expect(oTobiJulo(array)).toBe(455); - }); - - test("It should return maximum numnber in the array", () => { - const array = ['34','44','455','54', ]; - expect(() => oTobiJulo(array)).toBe(455); - }); - - test("It should fail because helper function oTobiJulo accepts only an array of numbers as argument", () => { - const array = ['34','44','455','54','fsfghfsf', ]; - expect(() => oTobiJulo(array)).toThrow("element of array must be a number"); - }); -});