Skip to content

Commit

Permalink
fix: update FormData mock to handle form property correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Dec 24, 2024
1 parent 46035ba commit 8bcf5ab
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/resources/drafts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jest.mock('formdata-node', () => {
return {
FormData: jest.fn().mockImplementation(function(this: MockedFormData) {
const appendedData: Record<string, any> = {};
this.append = (key: string, value: any, _filename?: string) => {
if (value && typeof value === 'object' && 'content' in value) {
// Handle File objects
appendedData[key] = value.content;
} else {
appendedData[key] = value;
}
};
this._getAppendedData = () => appendedData;
// Ensure the form property also has access to _getAppendedData
(this as any).form = {
const form = {
append: (key: string, value: any, _filename?: string) => {
if (value && typeof value === 'object' && 'content' in value) {
// Handle File objects
appendedData[key] = value.content;
} else {
appendedData[key] = value;
}
},
_getAppendedData: () => appendedData,
};
Object.assign(this, form);
(this as any).form = this;
return this;
}),
File: jest.fn().mockImplementation((content: any[], name: string) => ({
Expand Down

0 comments on commit 8bcf5ab

Please sign in to comment.