Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
701 B
1
Indexable
Never
  describe('GET /users/:id', () => {
    it('should retrieve a user by ID', async () => {
      // Create a user in the database
      const createdUser = await UserModel.create(mockUser2);
      const response = await request(app).get(`/users/${createdUser._id}`);
      expect(response.status).to.equal(200);

      // The expected data should match mockUser2
      expect(response.body.data).to.deep.equal({
        _id: mockUser2._id,
        email: mockUser2.email,
      });
    });

    it('should handle user not found', async () => {
      const response = await request(app).get('/users/60f6a1b5f3c1ac3dc0a0a8a1');
      expect(response.status).to.equal(404);
    });
  });
Leave a Comment