Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for user routes #73

Merged
merged 28 commits into from
Sep 24, 2022
Merged

Add unit tests for user routes #73

merged 28 commits into from
Sep 24, 2022

Conversation

IsaacCheng9
Copy link
Owner

@IsaacCheng9 IsaacCheng9 commented Sep 24, 2022

Changes

  • Created a file, users.test.js for unit tests for the user routes.
  • Changed the endpoint to create a user to adhere to REST API conventions (POST /users/add -> POST /users).
  • Added an endpoint to get a user by their username: GET /users/:username
  • Added an endpoint to delete a user by their username: DELETE /users/:username

Note that we currently have open handles that we need to resolve.

Related Issues

  • Issue #32
    • This is the first step of the issue – further work is required for debts.js and expenses.js.

Testing

isaac@MBP16 server % npm test

> server@1.0.0 test
> jest --forceExit

  console.log
    Server is running at port 3001.

      at Server.log (app.js:44:11)

  console.log
    Connected successfully.

      at NativeConnection.log (app.js:38:11)

 PASS  routes/users.test.js
  ✓ GET /users (684 ms)
  ✓ POST /users (141 ms)
  ✓ GET /users/:username (29 ms)
  ✓ DELETE /users/:username (37 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.657 s
Ran all test suites.
Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?

Copy link
Collaborator

@gkSideProjects gkSideProjects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@IsaacCheng9 IsaacCheng9 merged commit 5f9021d into main Sep 24, 2022
@IsaacCheng9 IsaacCheng9 deleted the add-unit-tests branch September 24, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants