https://github.com/uzair-manzoor/testing-practice
Practical tests for JavaScript functions using the Jest library to make sure the AAA pattern has been followed. The purpose is to make tests easier for other developers to read and understand. Also TDD approach is been practiced
https://github.com/uzair-manzoor/testing-practice
javascript jest-tests strings-manipulation
Last synced: about 1 year ago
JSON representation
Practical tests for JavaScript functions using the Jest library to make sure the AAA pattern has been followed. The purpose is to make tests easier for other developers to read and understand. Also TDD approach is been practiced
- Host: GitHub
- URL: https://github.com/uzair-manzoor/testing-practice
- Owner: Uzair-Manzoor
- License: mit
- Created: 2023-07-25T16:24:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-25T17:56:49.000Z (almost 3 years ago)
- Last Synced: 2025-02-10T20:59:08.732Z (over 1 year ago)
- Topics: javascript, jest-tests, strings-manipulation
- Language: JavaScript
- Homepage:
- Size: 164 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Test
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.
## Table of Contents
- [Function Descriptions](#function-descriptions)
- [Getting Started](#getting-started)
- [Running the Tests](#running-the-tests)
## Function Descriptions
### stringLength(string)
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.
### reverseString(string)
The `reverseString` function takes a string as an argument and returns the reversed version of the string.
### Calculator Class
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.
### capitalize(string)
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.
## Getting Started
To get started with this project, follow these steps:
1. Clone the repository: `git clone https://github.com/Uzair-Manzoor/Testing-practice.git`
2. Install the dependencies: `npm install` or `yarn install` (replace with your preferred package manager)
## Running the Tests
You can run the tests by executing the following command:
```bash
npm test
```
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.
## Contributing
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.
## License
This project is licensed under the [MIT License](LICENSE).