From 14e487261b8ce473252fe6e1c502dc330b5516c6 Mon Sep 17 00:00:00 2001 From: schmanu Date: Wed, 4 Oct 2023 14:27:52 +0200 Subject: [PATCH] docs: comments in useMPCWallet test --- src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts b/src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts index d9e16fa7e5..09b7003153 100644 --- a/src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts +++ b/src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts @@ -15,7 +15,12 @@ import { ONBOARD_MPC_MODULE_LABEL } from '@/services/mpc/module' import { ethers } from 'ethers' import BN from 'bn.js' +/** time until mock login resolves */ const MOCK_LOGIN_TIME = 1000 + +/** + * Helper class for mocking MPC Core Kit login flow + */ class MockMPCCoreKit { status: COREKIT_STATUS = COREKIT_STATUS.INITIALIZED state: { @@ -27,6 +32,12 @@ class MockMPCCoreKit { private stateAfterLogin: COREKIT_STATUS private userInfoAfterLogin: UserInfo | undefined private expectedFactorKey: BN + /** + * + * @param stateAfterLogin State after loginWithOauth resolves + * @param userInfoAfterLogin User info to set in the state after loginWithOauth resolves + * @param expectedFactorKey For MFA login flow the expected factor key. If inputFactorKey gets called with the expected factor key the state switches to logged in + */ constructor(stateAfterLogin: COREKIT_STATUS, userInfoAfterLogin: UserInfo, expectedFactorKey: BN = new BN(-1)) { this.stateAfterLogin = stateAfterLogin this.userInfoAfterLogin = userInfoAfterLogin