File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
packages/keyring-controller/src Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -3156,6 +3156,26 @@ describe('KeyringController', () => {
31563156 expect ( result ) . toBe ( 'foo' ) ;
31573157 } ) ;
31583158 } ) ;
3159+
3160+ it ( 'should narrow the return type based on the handler return type' , async ( ) => {
3161+ const messenger = buildKeyringControllerMessenger <
3162+ | KeyringControllerActions
3163+ | KeyringControllerWithKeyringAction < MockKeyring , string >
3164+ | KeyringControllerWithKeyringAction < MockKeyring , number >
3165+ > ( ) ;
3166+ await withController ( { messenger } , async ( { controller } ) => {
3167+ const selector = { type : MockKeyring . type } ;
3168+ jest . spyOn ( controller , 'withKeyring' ) . mockResolvedValue ( 'foo' ) ;
3169+
3170+ const result : number = await messenger . call (
3171+ 'KeyringController:withKeyring' ,
3172+ selector ,
3173+ async ( _keyring : EthKeyring < Json > ) => 10 ,
3174+ ) ;
3175+
3176+ expect ( result ) . toBe ( 10 ) ;
3177+ } ) ;
3178+ } ) ;
31593179 } ) ;
31603180
31613181 describe ( 'prepareUserOperation' , ( ) => {
You can’t perform that action at this time.
0 commit comments