@@ -269,7 +269,7 @@ describe('Page Relationships Controller', () => {
269269 expect ( resolvePageIdsStub ) . to . not . have . been . called ;
270270 } ) ;
271271
272- it ( 'returns 400 with default message when non-ErrorWithStatusCode is thrown' , async ( ) => {
272+ it ( 'returns 400 with IMS token problem message when non-ErrorWithStatusCode is thrown' , async ( ) => {
273273 isAEMAuthoredSiteStub . returns ( true ) ;
274274 getIMSPromiseTokenStub . rejects ( new Error ( 'unexpected' ) ) ;
275275 const controller = PageRelationshipsController ( controllerContext ) ;
@@ -278,7 +278,20 @@ describe('Page Relationships Controller', () => {
278278 const body = await response . json ( ) ;
279279
280280 expect ( response . status ) . to . equal ( 400 ) ;
281- expect ( body . message ) . to . equal ( 'Missing Authorization header' ) ;
281+ expect ( body . message ) . to . equal ( 'Problem getting IMS token: unexpected' ) ;
282+ expect ( resolvePageIdsStub ) . to . not . have . been . called ;
283+ } ) ;
284+
285+ it ( 'returns 400 with Unknown error when thrown error has no message' , async ( ) => {
286+ isAEMAuthoredSiteStub . returns ( true ) ;
287+ getIMSPromiseTokenStub . rejects ( Object . assign ( new Error ( ) , { message : '' } ) ) ;
288+ const controller = PageRelationshipsController ( controllerContext ) ;
289+
290+ const response = await controller . getForOpportunity ( requestContext ) ;
291+ const body = await response . json ( ) ;
292+
293+ expect ( response . status ) . to . equal ( 400 ) ;
294+ expect ( body . message ) . to . equal ( 'Problem getting IMS token: Unknown error' ) ;
282295 expect ( resolvePageIdsStub ) . to . not . have . been . called ;
283296 } ) ;
284297
0 commit comments