Skip to content

Commit

Permalink
fix storybook query mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
eshark9312 committed Nov 29, 2023
1 parent 99164bb commit 0de0c5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
20 changes: 7 additions & 13 deletions packages/ui/src/app/pages/Validators/ValidatorList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')] },
},
},
],
],
},
}
},
},
Expand Down
10 changes: 3 additions & 7 deletions packages/ui/src/validators/hooks/useValidatorsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0de0c5b

Please sign in to comment.