test: add unit tests for messaging, comments, events, and user services

- Added comprehensive unit tests for `MessagesService`, `CommentsService`, `EventsGateway`, and enhancements in `UsersService`.
- Ensured proper mocking and test coverage for newly introduced dependencies like `EventsGateway` and `RBACService`.
This commit is contained in:
Mathis HERRIOT
2026-01-29 15:06:12 +01:00
parent 1be8571f26
commit 7b76942795
5 changed files with 223 additions and 0 deletions

View File

@@ -108,6 +108,7 @@ describe("UsersService", () => {
describe("findOne", () => {
it("should find a user", async () => {
mockUsersRepository.findOne.mockResolvedValue({ uuid: "uuid1" });
mockRbacService.getUserRoles.mockResolvedValue([]);
const result = await service.findOne("uuid1");
expect(result.uuid).toBe("uuid1");
});
@@ -139,6 +140,7 @@ describe("UsersService", () => {
describe("findByEmailHash", () => {
it("should call repository.findByEmailHash", async () => {
mockUsersRepository.findByEmailHash.mockResolvedValue({ uuid: "u1" });
mockRbacService.getUserRoles.mockResolvedValue([]);
const result = await service.findByEmailHash("hash");
expect(result.uuid).toBe("u1");
expect(mockUsersRepository.findByEmailHash).toHaveBeenCalledWith("hash");