Skip to content

Commit

Permalink
Fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
ironbeer committed May 27, 2024
1 parent d924a72 commit bd8b7b0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/services/__tests__/websocket.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { IncomingMessage } from 'http';
import { INestApplication } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import configuration from '../../config/configuration';
import { HttpModule } from '@nestjs/axios';
import * as WebSocket from 'ws';
import { WsAdapter } from '@nestjs/platform-ws';
import { getClientIp } from '@supercharge/request-ip';
import { when } from 'jest-when';
import { DatastoreService } from 'src/repositories';
import {
AllowCheckService,
Expand Down Expand Up @@ -43,8 +44,6 @@ describe('WebSocket Service', () => {
let app: INestApplication;
let datastore: DatastoreService;
let proxy: ProxyService;
let manager: WSClientManagerService;

beforeAll(async () => {
moduleRef = await Test.createTestingModule({
imports: [
Expand All @@ -61,19 +60,26 @@ describe('WebSocket Service', () => {
TypeCheckService,
DatastoreService,
RateLimitService,
WSGateway,
WSClientManagerService,
],
}).compile();

app = moduleRef.createNestApplication();
app.useWebSocketAdapter(new WsAdapter(app));

manager = moduleRef.get<WSClientManagerService>(WSClientManagerService);
proxy = moduleRef.get<ProxyService>(ProxyService);
datastore = moduleRef.get<DatastoreService>(DatastoreService);
});

let manager: WSClientManagerService;
beforeAll(() => {
const config = moduleRef.get<ConfigService>(ConfigService);
when(jest.spyOn(config, 'get'))
.calledWith('verseWSUrl' as any)
.mockReturnValue('dummy');

manager = new WSClientManagerService(config, proxy);
});

beforeEach(() => {
jest.resetAllMocks();
});
Expand Down

0 comments on commit bd8b7b0

Please sign in to comment.