From 0de0c5bfd9bc469bd98c7b90869178da9b8cc957 Mon Sep 17 00:00:00 2001 From: eshark9312 Date: Wed, 29 Nov 2023 10:37:48 -0500 Subject: [PATCH] fix storybook query mocking --- .../Validators/ValidatorList.stories.tsx | 20 +++++++------------ .../validators/hooks/useValidatorsList.tsx | 10 +++------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx b/packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx index 58a7bdb4cf..f1ed6b7582 100644 --- a/packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx +++ b/packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx @@ -153,20 +153,14 @@ export default { }, }, }, - queryNode: [ - { - query: GetMembersWithDetailsDocument, - resolver: ({ variables } = {}) => { - if (variables?.where) { - return { - loading: false, - data: { memberships: [member('alice'), member('bob'), member('charlie'), member('dave')] }, - } - } - return { loading: false, data: undefined } + gql: { + queries: [ + { + query: GetMembersWithDetailsDocument, + data: { memberships: [member('alice'), member('bob'), member('charlie'), member('dave')] }, }, - }, - ], + ], + }, } }, }, diff --git a/packages/ui/src/validators/hooks/useValidatorsList.tsx b/packages/ui/src/validators/hooks/useValidatorsList.tsx index b5c2420ebe..9bc85c1ae4 100644 --- a/packages/ui/src/validators/hooks/useValidatorsList.tsx +++ b/packages/ui/src/validators/hooks/useValidatorsList.tsx @@ -55,13 +55,9 @@ export const useValidatorsList = () => { } const getValidatorsInfo = (api: Api, validatorsWithMembership: ValidatorMembership[]) => { - return of(validatorsWithMembership).pipe( - switchMap((validatorsWithMembership) => { - const validatorAddresses = validatorsWithMembership.map(({ stashAccount }) => stashAccount) - const validatorInfoObservables = validatorAddresses.map((address) => getValidatorInfo(address, api)) - return combineLatest(validatorInfoObservables) - }) - ) + const validatorAddresses = validatorsWithMembership.map(({ stashAccount }) => stashAccount) + const validatorInfoObservables = validatorAddresses.map((address) => getValidatorInfo(address, api)) + return combineLatest(validatorInfoObservables) } const allValidators = useFirstObservableValue(