@@ -10,20 +10,27 @@ jest.mock('formdata-node', () => {
1010 return {
1111 FormData : jest . fn ( ) . mockImplementation ( function ( this : MockedFormData ) {
1212 const appendedData : Record < string , any > = { } ;
13- const form = {
14- append : ( key : string , value : any , _filename ?: string ) => {
15- if ( value && typeof value === 'object' && 'content' in value ) {
16- // Handle File objects
17- appendedData [ key ] = value . content ;
18- } else {
19- appendedData [ key ] = value ;
20- }
21- } ,
22- _getAppendedData : ( ) => appendedData ,
13+
14+ this . append = ( key : string , value : any , _filename ?: string ) => {
15+ if ( value && typeof value === 'object' && 'content' in value ) {
16+ // Handle File objects
17+ appendedData [ key ] = value . content ;
18+ } else {
19+ appendedData [ key ] = value ;
20+ }
2321 } ;
24- Object . assign ( this , form ) ;
25- ( this as any ) . form = this ;
26- return this ;
22+
23+ this . _getAppendedData = ( ) => appendedData ;
24+
25+ // Create a proxy to handle both direct access and form property access
26+ return new Proxy ( this , {
27+ get : ( target , prop ) => {
28+ if ( prop === 'form' ) {
29+ return target ;
30+ }
31+ return target [ prop as keyof typeof target ] ;
32+ }
33+ } ) ;
2734 } ) ,
2835 File : jest . fn ( ) . mockImplementation ( ( content : any [ ] , name : string ) => ( {
2936 content,
0 commit comments