@@ -8,11 +8,9 @@ import { ConfigService } from '@nestjs/config';
8
8
import { ClientProxy } from '@nestjs/microservices' ;
9
9
import { Test , TestingModule } from '@nestjs/testing' ;
10
10
import {
11
- createRmqContext ,
12
11
MockOryPermissionsService ,
13
12
MockOryRelationshipsService ,
14
13
} from '@ticketing/microservices/shared/testing' ;
15
- import { Channel } from 'amqp-connection-manager' ;
16
14
import { Model , Types } from 'mongoose' ;
17
15
18
16
import { TicketDocument } from '../tickets/schemas' ;
@@ -53,21 +51,17 @@ describe('OrdersMSController', () => {
53
51
it ( 'should call "OrdersService.expireById" and in case of success ack RMQ message' , async ( ) => {
54
52
// order coming from expiration-service
55
53
const order = { id : new Types . ObjectId ( ) . toHexString ( ) } as Order ;
56
- const context = createRmqContext ( ) ;
57
54
const ordersController = app . get ( OrdersMSController ) ;
58
55
const ordersService = app . get ( OrdersService ) ;
59
56
ordersService . expireById = jest . fn ( ( ) => Promise . resolve ( order ) ) ;
60
- context . getChannelRef ( ) . ack = jest . fn ( ) ;
61
57
//
62
- await ordersController . onExpiration ( order , context ) ;
58
+ await ordersController . onExpiration ( order ) ;
63
59
expect ( ordersService . expireById ) . toBeCalledWith ( order . id ) ;
64
- expect ( context . getChannelRef ( ) . ack ) . toBeCalled ( ) ;
65
60
} ) ;
66
61
67
62
it ( 'should call "OrdersService.expireById" and in case of error NOT ack RMQ message' , async ( ) => {
68
63
// order coming from expiration-service
69
64
const order = { id : new Types . ObjectId ( ) . toHexString ( ) } ;
70
- const context = createRmqContext ( ) ;
71
65
const expectedError = new Error ( 'Cannot find order' ) ;
72
66
const ordersController = app . get ( OrdersMSController ) ;
73
67
const ordersService = app . get ( OrdersService ) ;
@@ -76,17 +70,11 @@ describe('OrdersMSController', () => {
76
70
throw expectedError ;
77
71
} )
78
72
. 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 ( ) ;
83
73
//
84
- await expect (
85
- ordersController . onExpiration ( order , context ) ,
86
- ) . rejects . toThrowError ( expectedError ) ;
74
+ await expect ( ordersController . onExpiration ( order ) ) . rejects . toThrowError (
75
+ expectedError ,
76
+ ) ;
87
77
expect ( ordersService . expireById ) . toBeCalledWith ( order . id ) ;
88
- expect ( channel . ack ) . not . toBeCalled ( ) ;
89
- expect ( channel . nack ) . toBeCalled ( ) ;
90
78
} ) ;
91
79
} ) ;
92
80
} ) ;
0 commit comments