-
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
c9e5dba
commit af66477
Showing
15 changed files
with
151 additions
and
35 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
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
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
53 changes: 53 additions & 0 deletions
53
apps/web/src/components/Onboarding/VerificationFlow/useHandleVerify.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,53 @@ | ||
import { mockMnemonicAccount } from "@umami/core"; | ||
import { | ||
type UmamiStore, | ||
accountsActions, | ||
addTestAccount, | ||
makeStore, | ||
useGetDecryptedMnemonic, | ||
} from "@umami/state"; | ||
import { mnemonic1 } from "@umami/test-utils"; | ||
|
||
import { ImportantNoticeModal } from "./ImportantNoticeModal"; | ||
import { useHandleVerify } from "./useHandleVerify"; | ||
import { act, dynamicModalContextMock, renderHook } from "../../../testUtils"; | ||
import { SetupPassword } from "../SetupPassword"; | ||
|
||
jest.mock("@umami/state", () => ({ | ||
...jest.requireActual("@umami/state"), | ||
useGetDecryptedMnemonic: jest.fn(), | ||
})); | ||
|
||
let store: UmamiStore; | ||
|
||
beforeEach(() => { | ||
store = makeStore(); | ||
addTestAccount(store, mockMnemonicAccount(0, { isVerified: false })); | ||
}); | ||
|
||
describe("useHandleVerify", () => { | ||
it("should open SetupPassword modal if master password is not set", async () => { | ||
const { openWith } = dynamicModalContextMock; | ||
const { result } = renderHook(() => useHandleVerify(), { store }); | ||
|
||
await act(async () => await result.current()); | ||
|
||
expect(openWith).toHaveBeenCalledWith( | ||
<SetupPassword handleProceedToVerification={expect.any(Function)} /> | ||
); | ||
}); | ||
|
||
it("should open ImportantNoticeModal modal if master password is set", async () => { | ||
(useGetDecryptedMnemonic as jest.Mock).mockImplementation(() => () => mnemonic1); | ||
store.dispatch(accountsActions.setPassword("password")); | ||
|
||
const { openWith } = dynamicModalContextMock; | ||
const { result } = renderHook(() => useHandleVerify(), { store }); | ||
|
||
await act(() => result.current()); | ||
|
||
expect(openWith).toHaveBeenCalledWith(<ImportantNoticeModal seedPhrase={mnemonic1} />, { | ||
size: "xl", | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
apps/web/src/components/Onboarding/VerificationFlow/useIsAccountVerified.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,34 @@ | ||
import { mockMnemonicAccount, mockSocialAccount } from "@umami/core"; | ||
import { type UmamiStore, addTestAccount, makeStore } from "@umami/state"; | ||
|
||
import { useIsAccountVerified } from "./useIsAccountVerified"; | ||
import { renderHook } from "../../../testUtils"; | ||
|
||
let store: UmamiStore; | ||
|
||
beforeEach(() => { | ||
store = makeStore(); | ||
}); | ||
|
||
describe("useIsAccountVerified", () => { | ||
it("returns true if the account is not mnemonic", () => { | ||
addTestAccount(store, mockSocialAccount(0)); | ||
const { result } = renderHook(() => useIsAccountVerified(), { store }); | ||
|
||
expect(result.current).toBe(true); | ||
}); | ||
|
||
it("returns true if the account is mnemonic and verified", () => { | ||
addTestAccount(store, mockMnemonicAccount(0)); | ||
const { result } = renderHook(() => useIsAccountVerified(), { store }); | ||
|
||
expect(result.current).toBe(true); | ||
}); | ||
|
||
it("returns false if the account is mnemonic and not verified", () => { | ||
addTestAccount(store, mockMnemonicAccount(0, { isVerified: false })); | ||
const { result } = renderHook(() => useIsAccountVerified(), { store }); | ||
|
||
expect(result.current).toBe(false); | ||
}); | ||
}); |
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
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
af66477
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.