-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
743c928
commit 8292145
Showing
8 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...nents/AccountSelectorModal/DeriveMnemonicAccountModal/DeriveMnemonicAccountModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { mockMnemonicAccount } from "@umami/core"; | ||
import { type UmamiStore, addTestAccount, makeStore, useDeriveMnemonicAccount } from "@umami/state"; | ||
|
||
import { DeriveMnemonicAccountModal } from "./DeriveMnemonicAccountModal"; | ||
import { act, renderInModal, screen, userEvent, waitFor } from "../../../testUtils"; | ||
|
||
let store: UmamiStore; | ||
|
||
jest.mock("@umami/state", () => ({ | ||
...jest.requireActual("@umami/state"), | ||
useDeriveMnemonicAccount: jest.fn(), | ||
})); | ||
|
||
const mockDeriveMnemonicAccount = jest.fn(); | ||
|
||
beforeEach(() => { | ||
store = makeStore(); | ||
addTestAccount(store, mockMnemonicAccount(0)); | ||
|
||
jest.mocked(useDeriveMnemonicAccount).mockImplementation(() => mockDeriveMnemonicAccount); | ||
}); | ||
|
||
describe("<DeriveMnemonicAccountModal />", () => { | ||
it("renders the NameAccountModal with correct subtitle", async () => { | ||
const account = mockMnemonicAccount(0); | ||
await renderInModal(<DeriveMnemonicAccountModal account={account} />, store); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText("Name Your Account")).toBeVisible(); | ||
}); | ||
|
||
expect( | ||
screen.getByText(`Name the new account derived from seedphrase ${account.seedFingerPrint}`) | ||
).toBeVisible(); | ||
}); | ||
|
||
it("handles name submission and opens confirm password modal", async () => { | ||
const user = userEvent.setup(); | ||
|
||
const account = mockMnemonicAccount(0); | ||
await renderInModal(<DeriveMnemonicAccountModal account={account} />, store); | ||
await act(() => user.type(screen.getByLabelText("Account name"), "Test Account")); | ||
await act(() => user.click(screen.getByRole("button", { name: "Continue" }))); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId("master-password-modal")).toBeVisible(); | ||
}); | ||
}); | ||
|
||
it("derives mnemonic account on password submission", async () => { | ||
const user = userEvent.setup(); | ||
|
||
const account = mockMnemonicAccount(0); | ||
await renderInModal(<DeriveMnemonicAccountModal account={account} />, store); | ||
|
||
await act(() => user.type(screen.getByLabelText("Account name"), "Test Account")); | ||
await act(() => user.click(screen.getByRole("button", { name: "Continue" }))); | ||
await act(() => user.type(screen.getByLabelText("Password"), "test-password")); | ||
await act(() => user.click(screen.getByRole("button", { name: "Submit" }))); | ||
|
||
expect(mockDeriveMnemonicAccount).toHaveBeenCalledWith({ | ||
fingerPrint: account.seedFingerPrint, | ||
password: "test-password", | ||
label: "Test Account", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters