UNPKG

@metamask/multichain-account-service

Version:
23 lines 929 B
/* eslint-disable jsdoc/require-jsdoc */ import { isBip44Account } from "@metamask/account-api"; export function makeMockAccountProvider(accounts = []) { return { accounts, getAccount: jest.fn(), getAccounts: jest.fn(), createAccounts: jest.fn(), discoverAndCreateAccounts: jest.fn(), }; } export function setupAccountProvider({ accounts, mocks = makeMockAccountProvider(), filter = () => true, }) { // You can mock this and all other mocks will re-use that list // of accounts. mocks.accounts = accounts; const getAccounts = () => mocks.accounts.filter((account) => isBip44Account(account) && filter(account)); mocks.getAccounts.mockImplementation(getAccounts); mocks.getAccount.mockImplementation((id) => // Assuming this never fails. getAccounts().find((account) => account.id === id)); return mocks; } //# sourceMappingURL=providers.mjs.map