File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed
Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -10,31 +10,30 @@ jest.mock('formdata-node', () => {
1010 return {
1111 FormData : jest . fn ( ) . mockImplementation ( ( ) => {
1212 const appendedData : Record < string , any > = { } ;
13- const methods = {
14- append : ( key : string , value : any , _filename ?: string ) => {
13+
14+ const formData : MockedFormData = {
15+ append ( key : string , value : any ) {
1516 if ( value && typeof value === 'object' && 'content' in value ) {
1617 // Handle File objects
1718 appendedData [ key ] = value . content ;
1819 } else {
1920 appendedData [ key ] = value ;
2021 }
2122 } ,
22- _getAppendedData : ( ) => appendedData ,
23+ _getAppendedData ( ) {
24+ return appendedData ;
25+ }
2326 } ;
2427
25- // Create the base object with methods
26- const formData = Object . create ( Object . prototype , {
27- ...Object . getOwnPropertyDescriptors ( methods ) ,
28- form : {
29- get ( ) {
30- return formData ;
31- } ,
32- configurable : true ,
33- enumerable : true ,
34- } ,
28+ // Create a proxy to handle form property access
29+ return new Proxy ( formData , {
30+ get ( target , prop ) {
31+ if ( prop === 'form' ) {
32+ return target ;
33+ }
34+ return target [ prop as keyof typeof target ] ;
35+ }
3536 } ) ;
36-
37- return formData ;
3837 } ) ,
3938 File : jest . fn ( ) . mockImplementation ( ( content : any [ ] , name : string ) => ( {
4039 content,
You can’t perform that action at this time.
0 commit comments