Skip to content

Commit 1f5e84f

Browse files
committed
fix test
1 parent a9a54ca commit 1f5e84f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

__tests__/websocket.decorators.spec.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe('Websocket Decorators', () => {
311311
describe('@OnError', () => {
312312
for (const PlatformAdapter of platforms) {
313313
describe(PlatformAdapter.name, () => {
314-
it('should listen a close event', async () => {
314+
it('should listen a error event', async () => {
315315
@Injectable()
316316
class TestService {
317317
private errorMessage = '';
@@ -392,7 +392,14 @@ describe('Websocket Decorators', () => {
392392
describe('@OnMessage', () => {
393393
for (const PlatformAdapter of platforms) {
394394
describe(PlatformAdapter.name, () => {
395-
it('should listen a close event', async () => {
395+
it('should listen a message event', async () => {
396+
const eventData = {
397+
event: 'push',
398+
data: {
399+
test: 'test',
400+
},
401+
};
402+
396403
@Injectable()
397404
class TestService {
398405
private data: Record<any, any> = {};
@@ -404,14 +411,7 @@ describe('Websocket Decorators', () => {
404411

405412
@OnOpen()
406413
onOpen() {
407-
this.ws.send(
408-
JSON.stringify({
409-
event: 'push',
410-
data: {
411-
test: 'test',
412-
},
413-
}),
414-
);
414+
this.ws.send(JSON.stringify(eventData));
415415
}
416416

417417
@OnMessage()
@@ -466,9 +466,11 @@ describe('Websocket Decorators', () => {
466466
.get('/')
467467
.expect(200)
468468
.expect((res) => {
469-
// console.log(res.body);
470-
// expect(res.body).toBeDefined();
471-
// expect(res.body.url).toEqual(`ws://localhost:${port}`);
469+
expect(res.body).toBeDefined();
470+
expect(res.body).toMatchObject({
471+
event: 'pop',
472+
data: eventData.data,
473+
});
472474
});
473475

474476
await app.close();

0 commit comments

Comments
 (0)