diff --git a/net/web/src/context/useAppContext.hook.js b/net/web/src/context/useAppContext.hook.js index f446dbfe..17991f25 100644 --- a/net/web/src/context/useAppContext.hook.js +++ b/net/web/src/context/useAppContext.hook.js @@ -37,10 +37,6 @@ export function useAppContext(websocket) { const channelContext = useContext(ChannelContext); const cardContext = useContext(CardContext); - useEffect(() => { - console.log(state.status); - }, [state.status]); - const setSession = (token) => { try { accountContext.actions.setToken(token); diff --git a/net/web/src/session/account/profile/Profile.jsx b/net/web/src/session/account/profile/Profile.jsx index 5a857852..aada0d96 100644 --- a/net/web/src/session/account/profile/Profile.jsx +++ b/net/web/src/session/account/profile/Profile.jsx @@ -1,5 +1,5 @@ import { useRef, useCallback } from 'react'; -import { Space, Modal, Input, Button } from 'antd'; +import { Modal, Input, Button } from 'antd'; import { ProfileWrapper, ProfileDetailsWrapper, ProfileImageWrapper, EditFooter } from './Profile.styled'; import { useProfile } from './useProfile.hook'; import { Logo } from 'logo/Logo'; diff --git a/net/web/src/session/account/profile/accountAccess/useAccountAccess.hook.js b/net/web/src/session/account/profile/accountAccess/useAccountAccess.hook.js index 1f8b706e..4b4813aa 100644 --- a/net/web/src/session/account/profile/accountAccess/useAccountAccess.hook.js +++ b/net/web/src/session/account/profile/accountAccess/useAccountAccess.hook.js @@ -3,9 +3,6 @@ import { AccountContext } from 'context/AccountContext'; import { ProfileContext } from 'context/ProfileContext'; import { generateSeal, unlockSeal, updateSeal } from 'context/sealUtil'; import { getUsername } from 'api/getUsername'; -import CryptoJS from 'crypto-js'; -import { JSEncrypt } from 'jsencrypt' - export function useAccountAccess() { const [state, setState] = useState({ @@ -70,7 +67,7 @@ export function useAccountAccess() { const sealUpdate = async () => { const updated = updateSeal(state.seal, state.sealKey, state.sealPassword); - await account.actions.updateSeal(state.seal); + await account.actions.updateSeal(updated.seal); }; const isEnabled = () => { diff --git a/net/web/test/User.test.js b/net/web/test/User.test.js new file mode 100644 index 00000000..4b482856 --- /dev/null +++ b/net/web/test/User.test.js @@ -0,0 +1,106 @@ +import React, { useState, useEffect, useContext } from 'react'; +import {render, act, screen, waitFor, fireEvent} from '@testing-library/react' +import { AppContextProvider } from 'context/AppContext'; +import { AccountContextProvider } from 'context/AccountContext'; +import { ProfileContext, ProfileContextProvider } from 'context/ProfileContext'; +import { StoreContextProvider } from 'context/StoreContext'; +import { ViewportContextProvider } from 'context/ViewportContext'; +import { useProfile } from 'session/account/profile/useProfile.hook'; +import * as fetchUtil from 'api/fetchUtil'; + +let profileHook; +let profileContext; +function ProfileView() { + const { state, actions } = useProfile(); + + const [name, setName] = useState(); + const [renderCount, setRenderCount] = useState(0); + const profile = useContext(ProfileContext); + profileContext = profile; + profileHook = actions; + + useEffect(() => { + const rendered = []; + setName(state.name); + setRenderCount(renderCount + 1); + }, [state]); + + return ( +