11import { mockDeep } from 'jest-mock-extended' ;
22import { Client } from 'utils' ;
3+ import { ConflictException , ValidationException } from 'domain/exceptions/' ;
34import { PutClientCommandParameters } from '../../app/put-client' ;
45import { AppDependencies , createApp } from '../../app' ;
5- import { ConflictException , ValidationException } from 'domain/exceptions/' ;
66
77const input : PutClientCommandParameters = {
8- clientId : 'test_client_id' ,
9- clientName : 'test_client_name' ,
10- meshMailboxSenderId : 'test_client_mesh_mailbox_id' ,
11- meshMailboxReportsId : 'test_client_mesh_workflow_id_suffix' ,
12- fallbackWaitTimeSeconds : 300 ,
13- routingConfigId : '1234' ,
14- } ;
8+ clientId : 'test_client_id' ,
9+ clientName : 'test_client_name' ,
10+ meshMailboxSenderId : 'test_client_mesh_mailbox_id' ,
11+ meshMailboxReportsId : 'test_client_mesh_workflow_id_suffix' ,
12+ fallbackWaitTimeSeconds : 300 ,
13+ routingConfigId : '1234' ,
14+ } ;
1515
1616const client : Client = {
17- clientId : 'test_client_id' ,
18- clientName : 'test_client_name' ,
19- meshMailboxSenderId : 'test_client_mesh_mailbox_id' ,
20- meshMailboxReportsId : 'test_client_mesh_workflow_id_suffix' ,
21- fallbackWaitTimeSeconds : 300 ,
22- routingConfigId : '1234' ,
23- } ;
17+ clientId : 'test_client_id' ,
18+ clientName : 'test_client_name' ,
19+ meshMailboxSenderId : 'test_client_mesh_mailbox_id' ,
20+ meshMailboxReportsId : 'test_client_mesh_workflow_id_suffix' ,
21+ fallbackWaitTimeSeconds : 300 ,
22+ routingConfigId : '1234' ,
23+ } ;
2424
2525function setup ( existingClients : Client [ ] = [ ] , createClientResponse = client ) {
2626 const mocks = mockDeep < AppDependencies > ( {
@@ -45,7 +45,7 @@ describe('putClient', () => {
4545 const { data, mocks } = setup ( [ ] ) ;
4646
4747 const app = createApp ( mocks ) ;
48- delete ( input . clientId ) ; // simulate no clientId provided
48+ delete input . clientId ; // simulate no clientId provided
4949 const result = await app . putClient ( input ) ;
5050
5151 expect ( mocks . domain . client . createClient ) . toHaveBeenCalledWith ( input ) ;
@@ -58,8 +58,8 @@ describe('putClient', () => {
5858 it ( 'creates a new client when existing clients, stores it in the client repository and returns it' , async ( ) => {
5959 const existingClient : Client = {
6060 ...client ,
61- clientId : " existing_client_id" ,
62- meshMailboxSenderId : " existing_mesh_mailbox_sender_id" ,
61+ clientId : ' existing_client_id' ,
62+ meshMailboxSenderId : ' existing_mesh_mailbox_sender_id' ,
6363 } ;
6464 const { data, mocks } = setup ( [ existingClient ] ) ;
6565
@@ -77,7 +77,7 @@ describe('putClient', () => {
7777 it ( 'Updates client when it exists, stores it in the client repository and returns it' , async ( ) => {
7878 const existingClient : Client = {
7979 ...client ,
80- meshMailboxSenderId : " existing_mesh_mailbox_sender_id" ,
80+ meshMailboxSenderId : ' existing_mesh_mailbox_sender_id' ,
8181 } ;
8282 const { data, mocks } = setup ( [ existingClient ] ) ;
8383
@@ -95,7 +95,7 @@ describe('putClient', () => {
9595 it ( 'throws an error when a different existing client has the same mailbox sender ID' , async ( ) => {
9696 const existingClient : Client = {
9797 ...client ,
98- clientId : " existing_client_id" ,
98+ clientId : ' existing_client_id' ,
9999 } ;
100100 const { mocks } = setup ( [ existingClient ] ) ;
101101
@@ -111,15 +111,19 @@ describe('putClient', () => {
111111 const newInvalidClient : Client = {
112112 ...client ,
113113 } ;
114- delete ( newInvalidClient . meshMailboxSenderId ) ;
114+ delete ( newInvalidClient as Partial < Client > ) . meshMailboxSenderId ;
115115
116116 const { mocks } = setup ( [ ] , newInvalidClient ) ;
117117
118118 const app = createApp ( mocks ) ;
119119
120- await expect ( app . putClient ( newInvalidClient ) ) . rejects . toThrow ( ValidationException ) ;
120+ await expect ( app . putClient ( newInvalidClient ) ) . rejects . toThrow (
121+ ValidationException ,
122+ ) ;
121123
122- expect ( mocks . domain . client . createClient ) . toHaveBeenCalledWith ( newInvalidClient ) ;
124+ expect ( mocks . domain . client . createClient ) . toHaveBeenCalledWith (
125+ newInvalidClient ,
126+ ) ;
123127 expect ( mocks . infra . clientRepository . putClient ) . toHaveBeenCalledTimes ( 0 ) ;
124128 } ) ;
125129} ) ;
0 commit comments