@@ -27,28 +27,28 @@ describe('RpcService', () => {
2727 } ) ;
2828
2929 describe ( 'execute' , ( ) => {
30- it ( 'should be able to execute a method' , ( ) => {
30+ it ( 'should execute a method' , async ( ) => {
3131 const service = new RpcService ( getHandlers ( ) , getHooks ( ) ) ;
32- expect ( service . execute ( 'method1' , [ 'test' ] ) ) . toBeNull ( ) ;
32+ expect ( await service . execute ( 'method1' , [ 'test' ] ) ) . toBeNull ( ) ;
3333 } ) ;
3434
35- it ( 'should be able to execute a method that uses a hook' , ( ) => {
35+ it ( 'should be able to execute a method that uses a hook' , async ( ) => {
3636 const service = new RpcService ( getHandlers ( ) , getHooks ( ) ) ;
37- expect ( service . execute ( 'method2' , [ 2 ] ) ) . toBe ( 4 ) ;
37+ expect ( await service . execute ( 'method2' , [ 2 ] ) ) . toBe ( 4 ) ;
3838 } ) ;
3939
40- it ( 'should throw an error if the method is not found' , ( ) => {
40+ it ( 'should throw an error if the method is not found' , async ( ) => {
4141 const service = new RpcService ( getHandlers ( ) , getHooks ( ) ) ;
4242 // @ts -expect-error Intentional destructive testing
43- expect ( async ( ) => service . execute ( 'method3' , [ 2 ] ) ) . not . toThrow (
43+ await expect ( service . execute ( 'method3' , [ 2 ] ) ) . rejects . toThrow (
4444 // This is not a _good_ error, but we only care about type safety in this instance.
45- 'TypeError: Cannot read properties of undefined (reading " params")' ,
45+ " Cannot read properties of undefined (reading ' params')" ,
4646 ) ;
4747 } ) ;
4848
49- it ( 'should throw if passed invalid params' , ( ) => {
49+ it ( 'should throw if passed invalid params' , async ( ) => {
5050 const service = new RpcService ( getHandlers ( ) , getHooks ( ) ) ;
51- expect ( async ( ) => service . execute ( 'method1' , [ 2 ] ) ) . toThrow (
51+ await expect ( service . execute ( 'method1' , [ 2 ] ) ) . rejects . toThrow (
5252 'Invalid params' ,
5353 ) ;
5454 } ) ;
0 commit comments