A simple environment for practicing unit tests
In this project we use a lib.js
file to hold simple functions which will be tested.
-
factorial - Expects a number as an input. The function returns the factorial of a given number (example -
factorial(5) == 1*2*3*4*5 = 120
). -
palindrome - Expects a string as an input. The function returns
true
if the given string or number is a palindrome, otherwise afalse
is returned. -
randomString - Expects a number indicating the string's length. The function generates a string containing only letters (
[a-z], [A-Z]
) and numbers ([0-9]
). -
shift - Expects a string and a number to indicate the desired number of shifts. The function returns a shifted string. A positive number will shift the string to the right. A Negative number will shift the string to the left. A value of zero will return the string as is with no shifts.
-
sort - Expects a string as an input. The function returns a sorted string in an ascending order.
-
Assert that the
factorial
function is returning the factorial of the given number. -
Assert that the
palindrome
function returns true if the given string is actually palindrome. -
Assert that the
palindrome
function returns true if the given number is actually palindrome. -
Assert that the
randomString
function returns a string with the length equal to the given number. -
Assert that the
shift
function returns a string shifted to the right when given a positive number of shifts. -
Assert that the
shift
function returns a string shifted to the left when given a negative number of shifts. -
Assert that the
shift
function returns the same input string when given a zero value as number of shifts. -
Assert that the
sort
function returns a new sorted string in ascending order.