Untitled
unknown
plain_text
2 years ago
701 B
10
Indexable
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);
});
});Editor is loading...
Leave a Comment