@cahil/utils › Globals › tests
▸ buildCaseArray(testInputs
: any[], output
: any): any[][]
Defined in src/tests/buildCaseArray.ts:20
Builds an array of test cases with a common output
example
const evenTests = [...buildCaseArray([2, 4, 6], true), ...buildCaseArray([1, 3, 5], false)]
Parameters:
Name | Type | Description |
---|---|---|
testInputs |
any[] | An array of test inputs to build into the case array |
output |
any | The single output that should be paired with every input |
Returns: any[][]
Returns the array of test cases
▸ runTest(testCase
: [any, any], func
: function, testVerb
: string): void
Defined in src/tests/runTest.ts:21
Runs a test based on input(s), if an array is provided then the items are passed as arguments to the function being tested, if anything else is provided then it is passed directly to the function
example
runTest([[3, 5], 8], (a, b) => a + b)
Parameters:
▪ testCase: [any, any]
A tuple of inputs and expected output
▪ func: function
The function to test
▸ (…args
: any[]): any
Parameters:
Name | Type |
---|---|
...args |
any[] |
▪Default value
testVerb: string= “toBe”
The jest expect
verb to use when testing - defaults to toBe
Returns: void