Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adityachandak287/unit-testing-demo
Repository for Unit Testing Presentation
https://github.com/adityachandak287/unit-testing-demo
testing unit-testing
Last synced: about 7 hours ago
JSON representation
Repository for Unit Testing Presentation
- Host: GitHub
- URL: https://github.com/adityachandak287/unit-testing-demo
- Owner: adityachandak287
- License: mit
- Created: 2022-10-07T09:43:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-09T20:15:53.000Z (about 2 years ago)
- Last Synced: 2024-05-28T23:39:05.221Z (6 months ago)
- Topics: testing, unit-testing
- Language: TypeScript
- Homepage: https://replit.com/@AdityaChandakDQ/unit-testing-demo
- Size: 717 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unit Testing Demo
## Commands
Run tests
```
npm run test
```Run tests in watch mode
```
npm run test:watch
```Run tests in watch mode and serve coverage report
```
npm run test-and-serve
```
API documentation
### GET /hello
```json
{ "msg": "Hello World" }
```### GET /
Get all users
```json
[
{
"id": 1,
"name": "test",
"email": "[email protected]"
}
]
```### GET /
Get user by id
```json
{
"id": 3,
"name": "test",
"email": "[email protected]"
}// Error Response if user does not exist
{
"statusCode": 404,
"message": "Not Found"
}
```### POST /
Create user
```json
// Request Body
{
"name": "John Doe",
"email": "[email protected]"
}// Response
{
"id": 2,
"name": "John Doe",
"email": "[email protected]"
}// Error Response
{
"statusCode": 400,
"message": "Bad Request"
}
```### PATCH /
Create user
```json
// Request Body
{
"name": "John Cena"
}// Response
{ "success": true }// Error Response
// If update fails
{
"statusCode": 400,
"message": "Bad Request"
}
// If user does not exist
{
"statusCode": 404,
"message": "Not Found"
}
```### DELETE /
Delete user by id
```json
// Response
{ "success": true }// Error Response if user does not exist
{
"statusCode": 404,
"message": "Not Found"
}
```### POST /pay
Verify if payment in given currency is valid for given amount in INR
```json
// Request Body
{
"amountPaid": 10,
"currency": "USD",
"inrToPay": 500
}// Response
{ "success": true }// Error Response
// If currency is not valid
{
"statusCode": 400,
"message": "Invalid currency",
"error": "Bad Request"
}// If given currency amount converted to INR is not >= inrToPay
{
"statusCode": 400,
"message": "Insufficient amount",
"error": "Bad Request"
}
```## Credits
- [Currency API](https://github.com/fawazahmed0/currency-api)
## Resources
- [Prisma Docs - Testing](https://www.prisma.io/docs/guides/testing/unit-testing)
- [NestJS Docs - Testing](https://docs.nestjs.com/fundamentals/testing)
- [Jest Docs](https://jestjs.io/docs/28.x/getting-started)