File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ jest.mock('formdata-node', () => {
1414 const getAppendedData = ( ) => appendedData ;
1515
1616 const createMockFormData = ( ) => {
17- const instance = {
17+ const mockInstance : MockedFormData = {
1818 append ( key : string , value : any ) : void {
1919 if ( value && typeof value === 'object' && 'content' in value ) {
2020 // Handle File objects
@@ -24,16 +24,23 @@ jest.mock('formdata-node', () => {
2424 }
2525 } ,
2626 _getAppendedData : getAppendedData ,
27+ form : null as any , // Will be set by proxy
2728 } ;
2829
29- Object . defineProperty ( instance , 'form' , {
30- get ( ) {
31- return instance ;
32- } ,
33- enumerable : true ,
30+ // Create a proxy to ensure all properties are available on both the instance and form
31+ const proxy : MockedFormData = new Proxy ( mockInstance , {
32+ get ( target : MockedFormData , prop : string | symbol ) : any {
33+ if ( prop === 'form' ) {
34+ return proxy ;
35+ }
36+ return target [ prop as keyof MockedFormData ] ;
37+ }
3438 } ) ;
3539
36- return instance ;
40+ // Set the form property to point to the proxy itself
41+ mockInstance . form = proxy ;
42+
43+ return proxy ;
3744 } ;
3845
3946 const mockFormData = createMockFormData ( ) as MockedFormData ;
You can’t perform that action at this time.
0 commit comments