1111 * TweetNaCl Mock - Centralized cryptographic function mocking
1212 * Provides consistent, deterministic mock implementations for encryption testing
1313 */
14- export const createTweetNaClMock = ( ) => {
14+ const mockCreateTweetNaCl = ( ) => {
1515 const mockSecretbox = jest . fn ( ( message : Uint8Array , nonce : Uint8Array , key : Uint8Array ) => {
1616 // Return deterministic mock encrypted result
1717 return new Uint8Array ( message . length + 16 ) ; // Add overhead for box
@@ -40,17 +40,19 @@ export const createTweetNaClMock = () => {
4040 } ;
4141} ;
4242
43+ export const createTweetNaClMock = mockCreateTweetNaCl ;
44+
4345/**
4446 * Apply TweetNaCl mock to jest
4547 */
4648export const mockTweetNaCl = ( ) => {
47- jest . mock ( 'tweetnacl' , ( ) => createTweetNaClMock ( ) ) ;
49+ jest . mock ( 'tweetnacl' , ( ) => mockCreateTweetNaCl ( ) ) ;
4850} ;
4951
5052/**
5153 * Crypto-browserify Mock - For PBKDF2 and other crypto operations
5254 */
53- export const createCryptoBrowserifyMock = ( ) => ( {
55+ const mockCreateCryptoBrowserify = ( ) => ( {
5456 pbkdf2 : jest . fn ( ( password , salt , iterations , keyLength , digest , callback ) => {
5557 // Simulate async operation
5658 setTimeout ( ( ) => {
@@ -64,17 +66,19 @@ export const createCryptoBrowserifyMock = () => ({
6466 } ) ,
6567} ) ;
6668
69+ export const createCryptoBrowserifyMock = mockCreateCryptoBrowserify ;
70+
6771/**
6872 * Apply crypto-browserify mock to jest
6973 */
7074export const mockCryptoBrowserify = ( ) => {
71- jest . mock ( 'crypto-browserify' , ( ) => createCryptoBrowserifyMock ( ) ) ;
75+ jest . mock ( 'crypto-browserify' , ( ) => mockCreateCryptoBrowserify ( ) ) ;
7276} ;
7377
7478/**
7579 * Argon2-browser Mock - For password hashing
7680 */
77- export const createArgon2BrowserMock = ( ) => ( {
81+ const mockCreateArgon2Browser = ( ) => ( {
7882 hash : jest . fn ( async ( options ) => {
7983 // Create deterministic hash based on password
8084 const passwordBytes = Buffer . from ( options . pass , 'utf8' ) ;
@@ -90,11 +94,13 @@ export const createArgon2BrowserMock = () => ({
9094 }
9195} ) ;
9296
97+ export const createArgon2BrowserMock = mockCreateArgon2Browser ;
98+
9399/**
94100 * Apply argon2-browser mock to jest
95101 */
96102export const mockArgon2Browser = ( ) => {
97- jest . mock ( 'argon2-browser' , ( ) => createArgon2BrowserMock ( ) ) ;
103+ jest . mock ( 'argon2-browser' , ( ) => mockCreateArgon2Browser ( ) ) ;
98104} ;
99105
100106// ===== DOM MOCKS =====
@@ -332,7 +338,7 @@ export const createMockWallet = () => ({
332338/**
333339 * Create mock for MUI components with forwardRef
334340 */
335- export const createMUIComponentMock = ( componentName : string ) => {
341+ const mockCreateMUIComponent = ( componentName : string ) => {
336342 const React = require ( 'react' ) ;
337343 return React . forwardRef ( ( props : any , ref : any ) => {
338344 return React . createElement ( 'div' , {
@@ -343,17 +349,19 @@ export const createMUIComponentMock = (componentName: string) => {
343349 } ) ;
344350} ;
345351
352+ export const createMUIComponentMock = mockCreateMUIComponent ;
353+
346354/**
347355 * Common MUI component mocks
348356 */
349357export const mockMUIComponents = ( ) => {
350- jest . mock ( '@mui/material/Grid' , ( ) => createMUIComponentMock ( 'Grid' ) ) ;
351- jest . mock ( '@mui/material/Box' , ( ) => createMUIComponentMock ( 'Box' ) ) ;
352- jest . mock ( '@mui/material/Typography' , ( ) => createMUIComponentMock ( 'Typography' ) ) ;
353- jest . mock ( '@mui/material/Button' , ( ) => createMUIComponentMock ( 'Button' ) ) ;
354- jest . mock ( '@mui/material/TextField' , ( ) => createMUIComponentMock ( 'TextField' ) ) ;
355- jest . mock ( '@mui/material/Card' , ( ) => createMUIComponentMock ( 'Card' ) ) ;
356- jest . mock ( '@mui/material/CardContent' , ( ) => createMUIComponentMock ( 'CardContent' ) ) ;
358+ jest . mock ( '@mui/material/Grid' , ( ) => mockCreateMUIComponent ( 'Grid' ) ) ;
359+ jest . mock ( '@mui/material/Box' , ( ) => mockCreateMUIComponent ( 'Box' ) ) ;
360+ jest . mock ( '@mui/material/Typography' , ( ) => mockCreateMUIComponent ( 'Typography' ) ) ;
361+ jest . mock ( '@mui/material/Button' , ( ) => mockCreateMUIComponent ( 'Button' ) ) ;
362+ jest . mock ( '@mui/material/TextField' , ( ) => mockCreateMUIComponent ( 'TextField' ) ) ;
363+ jest . mock ( '@mui/material/Card' , ( ) => mockCreateMUIComponent ( 'Card' ) ) ;
364+ jest . mock ( '@mui/material/CardContent' , ( ) => mockCreateMUIComponent ( 'CardContent' ) ) ;
357365} ;
358366
359367// ===== TIMER MOCKS =====
0 commit comments