@@ -47,6 +47,7 @@ describe("SignatureV4MultiRegion", () => {
4747
4848  beforeEach ( ( )  =>  { 
4949    signatureV4CrtContainer . CrtSignerV4  =  CrtSignerV4  as  any ; 
50+     signatureV4aContainer . SignatureV4a  =  SignatureV4a  as  any ; 
5051    vi . clearAllMocks ( ) ; 
5152  } ) ; 
5253
@@ -66,13 +67,6 @@ describe("SignatureV4MultiRegion", () => {
6667    expect ( SignatureV4S3Express . mock . instances [ 0 ] . presign ) . toBeCalledTimes ( 1 ) ; 
6768  } ) ; 
6869
69-   it ( "should sign with SigV4a signer if mult_region option is set" ,  async  ( )  =>  { 
70-     const  signer  =  new  SignatureV4MultiRegion ( params ) ; 
71-     await  signer . presign ( minimalRequest ,  {  signingRegion : "*"  } ) ; 
72-     //@ts -ignore 
73-     expect ( CrtSignerV4 . mock . instances [ 0 ] . presign ) . toBeCalledTimes ( 1 ) ; 
74-   } ) ; 
75- 
7670  it ( "should presign with SigV4 signer" ,  async  ( )  =>  { 
7771    const  signer  =  new  SignatureV4MultiRegion ( params ) ; 
7872    await  signer . presign ( minimalRequest ,  {  signingRegion : "*"  } ) ; 
@@ -83,15 +77,9 @@ describe("SignatureV4MultiRegion", () => {
8377  it ( "should sign with SigV4a signer if signingRegion is '*'" ,  async  ( )  =>  { 
8478    const  signer  =  new  SignatureV4MultiRegion ( params ) ; 
8579    await  signer . sign ( minimalRequest ,  {  signingRegion : "*"  } ) ; 
86-     expect ( SignatureV4a . prototype . sign ) . toBeCalledTimes ( 1 ) ; 
87-   } ) ; 
88- 
89-   it ( "should throw if sign with SigV4a in unsupported runtime" ,  async  ( )  =>  { 
90-     expect . assertions ( 1 ) ; 
91-     const  signer  =  new  SignatureV4MultiRegion ( {  ...params ,  runtime : "browser"  } ) ; 
92-     await  expect ( async  ( )  =>  await  signer . sign ( minimalRequest ,  {  signingRegion : "*"  } ) ) . rejects . toThrow ( 
93-       "This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js" 
94-     ) ; 
80+     //@ts -ignore Check the CrtSignerV4 mock instance instead 
81+     expect ( CrtSignerV4 . mock . instances [ 0 ] . sign ) . toBeCalledTimes ( 1 ) ; 
82+     expect ( SignatureV4a . prototype . sign ) . toBeCalledTimes ( 0 ) ;  // Ensure JS signer was not called 
9583  } ) ; 
9684
9785  it ( "should use SignatureV4a if CrtSignerV4 is not available" ,  async  ( )  =>  { 
@@ -149,7 +137,8 @@ describe("SignatureV4MultiRegion", () => {
149137    signatureV4CrtContainer . CrtSignerV4  =  null ; 
150138    expect . assertions ( 1 ) ; 
151139    const  signer  =  new  SignatureV4MultiRegion ( {  ...params  } ) ; 
152-     await  expect ( async  ( )  =>  await  signer . sign ( minimalRequest ,  {  signingRegion : "*"  } ) ) . rejects . toThrow ( 
140+     // // Use presign here, as presign with '*' requires CRT and has no JS fallback 
141+     await  expect ( async  ( )  =>  await  signer . presign ( minimalRequest ,  {  signingRegion : "*"  } ) ) . rejects . toThrow ( 
153142      "\n"  + 
154143        `Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. \n`  + 
155144        `You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] `  + 
0 commit comments