Skip to content

Commit

Permalink
fix: improve FormData mock to handle nested form property access
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Dec 25, 2024
1 parent c2c7c70 commit 2c275d1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/resources/drafts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ jest.mock('formdata-node', () => {
this._getAppendedData = () => appendedData;

// Create a proxy to handle both direct access and form property access
return new Proxy(this, {
get: (target, prop) => {
const proxyHandler = {
get: (target: any, prop: string | symbol) => {
if (prop === 'form') {
return target;
// Return a new proxy for the form property to maintain the chain
return new Proxy(target, proxyHandler);
}
return target[prop as keyof typeof target];
return target[prop];
},
});
};
return new Proxy(this, proxyHandler);
}),
File: jest.fn().mockImplementation((content: any[], name: string) => ({
content,
Expand Down

0 comments on commit 2c275d1

Please sign in to comment.