File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,18 @@ console.log = (input) => {
21
21
tempResult . logs === '' ? input + '' : tempResult . logs + '\n' + input ;
22
22
} ;
23
23
24
+ /**
25
+ We are overloading this function. It can be used with either 2 or 3 params
26
+ * using it with 2 params means the first param is the `title` and the second is the `callback`
27
+ * using it with 3 params means the first param is the test `input`, the second is the `title` and the third is the `callback`
28
+ */
24
29
// Declares a test unit
25
30
const test = ( param1 , param2 , param3 ) => {
26
31
let input ;
27
32
let title ;
28
33
let cb ;
34
+ // This check sets the function up for overloading the params. If the second param is a function, we ignore the third param
35
+ // if the second param is not a function, we expect 3 params to be provided.
29
36
if ( typeof param2 == 'function' ) {
30
37
title = param1 ;
31
38
cb = param2 ;
Original file line number Diff line number Diff line change @@ -21,11 +21,18 @@ console.log = (input) => {
21
21
tempResult . logs === '' ? input + '' : tempResult . logs + '\n' + input ;
22
22
} ;
23
23
24
+ /**
25
+ We are overloading this function. It can be used with either 2 or 3 params
26
+ * using it with 2 params means the first param is the `title` and the second is the `callback`
27
+ * using it with 3 params means the first param is the test `input`, the second is the `title` and the third is the `callback`
28
+ */
24
29
// Declares a test unit
25
30
const test = ( param1 , param2 , param3 ) => {
26
31
let input ;
27
32
let title ;
28
33
let cb ;
34
+ // This check sets the function up for overloading the params. If the second param is a function, we ignore the third param
35
+ // if the second param is not a function, we expect 3 params to be provided.
29
36
if ( typeof param2 == 'function' ) {
30
37
title = param1 ;
31
38
cb = param2 ;
You can’t perform that action at this time.
0 commit comments