Skip to content

Commit

Permalink
docs: update users router documentation for login, add response body
Browse files Browse the repository at this point in the history
  • Loading branch information
heystone999 committed Mar 14, 2024
1 parent c8d9886 commit 19e5836
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion memo-backend/users_routes_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- **Status**: 201 Created
- **Body**:
- `message`: String - Confirmation message.
- `username`: String - The username of the user.
- `email`: String - The email address of the user.
- `id`: String - userId.

## Login

Expand All @@ -30,4 +33,7 @@
- **Status**: 200 OK
- **Body**:
- `message`: String - Confirmation message.
- `token`: String - JWT token for authentication.
- `token`: String - JWT token for authentication.
- `username`: String - The username of the user.
- `email`: String - The email address of the user.
- `id`: String - userId.

2 comments on commit 19e5836

@heystone999
Copy link
Owner Author

Choose a reason for hiding this comment

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

Coverage report for backend

Caution

Test run failed

St.❔
Category Percentage Covered / Total
πŸ”΄ Statements 50.25% 99/197
πŸ”΄ Branches 30.16% 19/63
πŸ”΄ Functions 22.22% 4/18
πŸ”΄ Lines 50.25% 99/197

Test suite run failed

Failed tests: 2/7. Failed suites: 2/3.
  ● POST /api/habits β€Ί should add a new habit

    expected 200 "OK", got 401 "Unauthorized"

      30 |     .post('/api/login')
      31 |     .send({ username: username, password: password })
    > 32 |     .expect(200);
         |      ^
      33 |
      34 |   // Extract the token from the response body
      35 |   token = res.body.token;

      at Object.expect (tests/habits.test.js:32:6)
      ----
      at Test._assertStatus (node_modules/supertest/lib/test.js:252:14)
      at assertFn (node_modules/supertest/lib/test.js:308:13)
      at Test.fn [as _assertFunction] (node_modules/supertest/lib/test.js:285:13)
      at Test._assertFunction [as assert] (node_modules/supertest/lib/test.js:164:23)
      at Server.assert (node_modules/supertest/lib/test.js:120:14)


  ● User endpoints β€Ί POST /api/users creates a new user

    expect(received).toHaveLength(expected)

    Expected length: 1
    Received length: 2
    Received array:  [{"email": "[email protected]", "id": "65f3405e9c6be479ce7f162b", "username": "testuser"}, {"email": "[email protected]", "id": "65f3405eefb2d90364c3996b", "username": "newuser"}]

      31 |
      32 |     const users = await User.find({})
    > 33 |     expect(users).toHaveLength(1)
         |                   ^
      34 |     expect(users[0].username).toBe(newUser.username)
      35 |
      36 |     const passwordMatches = await bcrypt.compare(newUser.password, users[0].passwordHash)

      at Object.toHaveLength (tests/users.test.js:33:19)

Report generated by πŸ§ͺjest coverage report action from 19e5836

@heystone999
Copy link
Owner Author

Choose a reason for hiding this comment

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

Coverage report for fronend

St.❔
Category Percentage Covered / Total
πŸ”΄ Statements 40.14% 297/740
πŸ”΄ Branches 28.38% 84/296
πŸ”΄ Functions 31.6% 67/212
πŸ”΄ Lines 40.51% 284/701

Test suite run success

13 tests passing in 4 suites.

Report generated by πŸ§ͺjest coverage report action from 19e5836

Please sign in to comment.