test: rename variables and format multiline assertion in events gateway spec
- Renamed `jwtService` to `_jwtService` to align with conventions for unused test variables. - Adjusted multiline assertion formatting for improved readability.
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
import { ConfigService } from "@nestjs/config";
|
import { ConfigService } from "@nestjs/config";
|
||||||
import { Test, TestingModule } from "@nestjs/testing";
|
import { Test, TestingModule } from "@nestjs/testing";
|
||||||
import { Server } from "socket.io";
|
|
||||||
import { JwtService } from "../crypto/services/jwt.service";
|
import { JwtService } from "../crypto/services/jwt.service";
|
||||||
import { EventsGateway } from "./events.gateway";
|
import { EventsGateway } from "./events.gateway";
|
||||||
|
|
||||||
describe("EventsGateway", () => {
|
describe("EventsGateway", () => {
|
||||||
let gateway: EventsGateway;
|
let gateway: EventsGateway;
|
||||||
let jwtService: JwtService;
|
let _jwtService: JwtService;
|
||||||
|
|
||||||
const mockJwtService = {
|
const mockJwtService = {
|
||||||
verifyJwt: jest.fn(),
|
verifyJwt: jest.fn(),
|
||||||
@@ -26,7 +25,7 @@ describe("EventsGateway", () => {
|
|||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
gateway = module.get<EventsGateway>(EventsGateway);
|
gateway = module.get<EventsGateway>(EventsGateway);
|
||||||
jwtService = module.get<JwtService>(JwtService);
|
_jwtService = module.get<JwtService>(JwtService);
|
||||||
gateway.server = {
|
gateway.server = {
|
||||||
to: jest.fn().mockReturnThis(),
|
to: jest.fn().mockReturnThis(),
|
||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
@@ -46,7 +45,10 @@ describe("EventsGateway", () => {
|
|||||||
gateway.sendToUser(userId, event, data);
|
gateway.sendToUser(userId, event, data);
|
||||||
|
|
||||||
expect(gateway.server.to).toHaveBeenCalledWith(`user:${userId}`);
|
expect(gateway.server.to).toHaveBeenCalledWith(`user:${userId}`);
|
||||||
expect(gateway.server.to(`user:${userId}`).emit).toHaveBeenCalledWith(event, data);
|
expect(gateway.server.to(`user:${userId}`).emit).toHaveBeenCalledWith(
|
||||||
|
event,
|
||||||
|
data,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user