Skip to content

Commit aa72877

Browse files
committed
test: remove obsolete assertions
1 parent 9b53ffa commit aa72877

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

apps/orders/src/app/orders/orders-ms.controller.spec.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import { ConfigService } from '@nestjs/config';
88
import { ClientProxy } from '@nestjs/microservices';
99
import { Test, TestingModule } from '@nestjs/testing';
1010
import {
11-
createRmqContext,
1211
MockOryPermissionsService,
1312
MockOryRelationshipsService,
1413
} from '@ticketing/microservices/shared/testing';
15-
import { Channel } from 'amqp-connection-manager';
1614
import { Model, Types } from 'mongoose';
1715

1816
import { TicketDocument } from '../tickets/schemas';
@@ -53,21 +51,17 @@ describe('OrdersMSController', () => {
5351
it('should call "OrdersService.expireById" and in case of success ack RMQ message', async () => {
5452
// order coming from expiration-service
5553
const order = { id: new Types.ObjectId().toHexString() } as Order;
56-
const context = createRmqContext();
5754
const ordersController = app.get(OrdersMSController);
5855
const ordersService = app.get(OrdersService);
5956
ordersService.expireById = jest.fn(() => Promise.resolve(order));
60-
context.getChannelRef().ack = jest.fn();
6157
//
62-
await ordersController.onExpiration(order, context);
58+
await ordersController.onExpiration(order);
6359
expect(ordersService.expireById).toBeCalledWith(order.id);
64-
expect(context.getChannelRef().ack).toBeCalled();
6560
});
6661

6762
it('should call "OrdersService.expireById" and in case of error NOT ack RMQ message', async () => {
6863
// order coming from expiration-service
6964
const order = { id: new Types.ObjectId().toHexString() };
70-
const context = createRmqContext();
7165
const expectedError = new Error('Cannot find order');
7266
const ordersController = app.get(OrdersMSController);
7367
const ordersService = app.get(OrdersService);
@@ -76,17 +70,11 @@ describe('OrdersMSController', () => {
7670
throw expectedError;
7771
})
7872
.mockRejectedValueOnce(expectedError);
79-
context.getChannelRef().ack = jest.fn();
80-
const channel = context.getChannelRef() as Channel;
81-
channel.ack = jest.fn();
82-
channel.nack = jest.fn();
8373
//
84-
await expect(
85-
ordersController.onExpiration(order, context),
86-
).rejects.toThrowError(expectedError);
74+
await expect(ordersController.onExpiration(order)).rejects.toThrowError(
75+
expectedError,
76+
);
8777
expect(ordersService.expireById).toBeCalledWith(order.id);
88-
expect(channel.ack).not.toBeCalled();
89-
expect(channel.nack).toBeCalled();
9078
});
9179
});
9280
});

0 commit comments

Comments
 (0)