-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Dada a classe:
class UsersController {
constructor(User, AuthService) {
this.User = User;
this.AuthService = AuthService;
}
async authenticate(req, res) {
const authService = new this.AuthService(this.User);
const user = await authService.authenticate(req.body);
if (!user) {
return res.sendStatus(401);
}
const token = this.AuthService.generateToken({
name: user.name,
email: user.email,
password: user.password,
role: user.role
});
return res.send({ token });
}
}
export default UsersController;
os testes unitários apresentam o erro:
Controller: Users
login
should return 401 when the user can not be found:
TypeError: this.AuthService is not a constructor
at UsersController.authenticate (src/controllers/users.js:69:29)
at Context.<anonymous> (test/unit/controllers/users_spec.js:298:35)
at processImmediate (node:internal/timers:464:21)
para ver o codigo completo atual pode verificar em:
https://github.com/gfkauer/to-do-api
Metadata
Metadata
Assignees
Labels
No labels