Skip to content

Commit 2c275d1

Browse files
fix: improve FormData mock to handle nested form property access
1 parent c2c7c70 commit 2c275d1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/resources/drafts.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ jest.mock('formdata-node', () => {
2323
this._getAppendedData = () => appendedData;
2424

2525
// Create a proxy to handle both direct access and form property access
26-
return new Proxy(this, {
27-
get: (target, prop) => {
26+
const proxyHandler = {
27+
get: (target: any, prop: string | symbol) => {
2828
if (prop === 'form') {
29-
return target;
29+
// Return a new proxy for the form property to maintain the chain
30+
return new Proxy(target, proxyHandler);
3031
}
31-
return target[prop as keyof typeof target];
32+
return target[prop];
3233
},
33-
});
34+
};
35+
return new Proxy(this, proxyHandler);
3436
}),
3537
File: jest.fn().mockImplementation((content: any[], name: string) => ({
3638
content,

0 commit comments

Comments
 (0)