@@ -107,7 +107,7 @@ describe('createBucket', () => {
107
107
) ;
108
108
} ) ;
109
109
110
- it ( 'excepts if invalid bucket head' , async ( ) => {
110
+ it ( 'responds with error when invalid bucket head' , async ( ) => {
111
111
// request object
112
112
const req = {
113
113
body : { bucket : REQUEST_BUCKET , region : 'test' } ,
@@ -126,13 +126,15 @@ describe('createBucket', () => {
126
126
throw new Error ( ) ;
127
127
} ) ;
128
128
129
- await expect ( controller . createBucket ( req , res , next ) ) . rejects . toThrow ( ) ;
129
+ await controller . createBucket ( req , res , next ) ;
130
130
131
131
expect ( headBucketSpy ) . toHaveBeenCalledTimes ( 1 ) ;
132
132
expect ( headBucketSpy ) . toHaveBeenCalledWith ( req . body ) ;
133
133
expect ( getCurrentIdentitySpy ) . toHaveBeenCalledTimes ( 0 ) ;
134
134
expect ( getCurrentUserIdSpy ) . toHaveBeenCalledTimes ( 0 ) ;
135
135
expect ( createSpy ) . toHaveBeenCalledTimes ( 0 ) ;
136
+ expect ( next ) . toHaveBeenCalledTimes ( 1 ) ;
137
+ expect ( next ) . toHaveBeenCalledWith ( expect . any ( Problem ) ) ;
136
138
} ) ;
137
139
138
140
it ( 'nexts an error if the bucket service fails to create' , async ( ) => {
@@ -167,7 +169,7 @@ describe('createBucket', () => {
167
169
expect ( getCurrentUserIdSpy ) . toHaveBeenCalledWith ( USR_IDENTITY ) ;
168
170
expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
169
171
expect ( createSpy ) . toHaveBeenCalledWith ( { ...req . body , userId : USR_ID } ) ;
170
-
172
+
171
173
expect ( next ) . toHaveBeenCalledTimes ( 1 ) ;
172
174
expect ( next ) . toHaveBeenCalledWith (
173
175
new Problem ( 502 , 'Unknown BucketService Error' )
@@ -213,7 +215,7 @@ describe('createBucket', () => {
213
215
expect ( createSpy ) . toHaveBeenCalledWith ( { ...req . body , userId : USR_ID } ) ;
214
216
expect ( checkGrantPermissionsSpy ) . toHaveBeenCalledTimes ( 1 ) ;
215
217
expect ( checkGrantPermissionsSpy ) . toHaveBeenCalledWith ( { ...req . body , userId : USR_ID } ) ;
216
-
218
+
217
219
expect ( res . status ) . toHaveBeenCalledWith ( 201 ) ;
218
220
} ) ;
219
221
} ) ;
0 commit comments