This repository contains JavaScript functions and corresponding tests written using the Jest library. The tests follow the AAA (Arrange-Act-Assert) pattern and aim to ensure the correctness of the implemented functions.
This function takes a string as an argument and returns the number of characters in the string. It also checks if the string is at least 1 character long and not longer than 10 characters. If these conditions are not met, the function throws errors.
The reverseString
function takes a string as an argument and returns the reversed version of the string.
The Calculator
class provides basic arithmetic operations: add
, subtract
, multiply
, and divide
. Each method takes two numbers as arguments and performs the corresponding operation. The divide
method checks for division by zero and throws an error if encountered.
The capitalize
function takes a string as an argument and returns the same string with the first character capitalized. It throws an error if the input is not a string.
To get started with this project, follow these steps:
- Clone the repository:
https://github.com/Abbas-Aljuaifari/Testing-Test.git
- Install the dependencies:
npm install
oryarn install
(replace with your preferred package manager)
You can run the tests by executing the following command:
npx jest
This command will run all the test suites and display the results. Make sure you have installed the dependencies before running the tests.
Feel free to explore the test files in the repository to see the specific test cases and assertions for each function.
Contributions to this project are welcome. If you find any issues or would like to add new tests or functions, please open an issue or submit a pull request.
This project is licensed under the MIT License.