mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 15:08:37 +00:00
36 lines
887 B
TypeScript
36 lines
887 B
TypeScript
import { INestApplication } from '@nestjs/common';
|
|
import { Test } from '@nestjs/testing';
|
|
import { expect } from 'chai';
|
|
import { io } from 'socket.io-client';
|
|
import { ErrorGateway } from '../src/error.gateway';
|
|
|
|
describe('ErrorGateway', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
const testingModule = await Test.createTestingModule({
|
|
providers: [ErrorGateway],
|
|
}).compile();
|
|
app = testingModule.createNestApplication();
|
|
await app.listen(3000);
|
|
});
|
|
|
|
it(`should handle error`, async () => {
|
|
const ws = io('http://localhost:8080');
|
|
ws.emit('push', {
|
|
test: 'test',
|
|
});
|
|
await new Promise<void>(resolve =>
|
|
ws.on('exception', data => {
|
|
expect(data).to.be.eql({
|
|
status: 'error',
|
|
message: 'test',
|
|
});
|
|
resolve();
|
|
}),
|
|
);
|
|
});
|
|
|
|
afterEach(() => app.close());
|
|
});
|