This repository contains the implementation and testing of basic JavaScript functions, along with some simple API endpoint tests.
- Clone the repository:
git clone https://github.com/FarooQ-2113/NODE_JS_RESTFULL_API.git cd NODE_JS_RESTFULL_API npm install npm run testAll
This section describes the basic JavaScript functions being tested.
Test Description:
- Verifies that the function
getDataTypes
returns the correct data types for number, string, array, and object.
Test Description:
- Tests the
sumUsingForLoop
function to ensure it correctly sums numbers from 1 to a given number using a for loop.
Test Description:
- Tests the
sumUsingWhileLoop
function to ensure it correctly sums numbers from 1 to a given number using a while loop.
Test Description:
- Verifies that the function
isPositive
correctly identifies if a number is positive.
Test Description:
- Tests the
isEven
function to determine if a number is even or odd.
Test Description:
- Verifies that the function
containsSubstring
correctly identifies if a string contains a specific substring.
This section describes the API tests for various endpoints.
Test Descriptions:
- GET /api/simpleApi: Verifies the GET request returns a status 200 and a response message.
- POST /api/simpleApi: Ensures the POST request returns a status 200 and a response message.
- PUT /api/simpleApi: Confirms the PUT request returns a status 200 and a response message.
- DELETE /api/simpleApi: Ensures the DELETE request returns a status 200 and a response message.
Test Descriptions:
- POST /api/items/create: Tests creating an item and checks the response status and content.
- GET /api/items/getAll: Verifies retrieval of all items and checks the response status and content.
- GET /api/items/getById/:id: Ensures retrieval of a specific item by ID and checks the response status and content.
- PUT /api/items/updateById/:id: Tests updating an item and checks the response status and content.
- DELETE /api/items/deleteById/:id: Confirms deletion of an item and checks the response status and content.
Test Descriptions:
- POST /api/products/create: Tests creating a product and checks the response status and content.
- GET /api/products/getAll: Verifies retrieval of all products and checks the response status and content.
- GET /api/products/getById/:id: Ensures retrieval of a specific product by ID and checks the response status and content.
- PUT /api/products/updateById/:id: Tests updating a product and checks the response status and content.
- DELETE /api/products/deleteById/:id: Confirms deletion of a product and checks the response status and content.
Test Descriptions:
- POST /api/users/signup: Verifies user signup and checks the response status and content.
- POST /api/users/login: Ensures user login, token generation, and checks the response status and content.
- GET /api/users/protected: Tests access to protected content with and without a valid token and checks the response status and content.