Skip to content

Commit

Permalink
fix: accounts update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthecat committed Jan 13, 2025
1 parent 2568fac commit af2794b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/renderer/domains/network/accounts/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('accounts model', () => {
it('should successfully update account', async () => {
const scope = fork({
values: [[accountsDomainModel.__test.$list, accounts]],
handlers: [[accountsDomainModel.updateAccounts, () => true]],
handlers: [[accountsDomainModel.updateAccount, () => true]],
});

const draft: AnyAccountDraft = {
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/domains/network/accounts/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ sample({
source: $accounts,
filter: (_, { result: successful }) => successful,
fn: (accounts, { params: draft }) => {
console.log({ accounts, draft });
const draftId = accountsService.uniqId(draft);

return accounts.map(a => (a.id === draftId ? ({ ...a, ...draft } as AnyAccount) : a)) as AnyAccount[];
return accounts.map(a => (accountsService.uniqId(a) === draftId ? { ...a, ...draft } : a));
},
target: $accounts,
});
Expand All @@ -93,7 +94,9 @@ sample({
return acc;
}, {});

return accounts.map(a => (a.id in draftsMap ? ({ ...a, ...draftsMap[a.id] } as AnyAccount) : a)) as AnyAccount[];
return accounts.map(a =>
accountsService.uniqId(a) in draftsMap ? { ...a, ...draftsMap[accountsService.uniqId(a)] } : a,
);
},
target: $accounts,
});
Expand Down

0 comments on commit af2794b

Please sign in to comment.