From 7bdd826418c862a74be033cb5aedcb9f3c96cc3e Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Mon, 3 Mar 2025 00:19:50 +0500 Subject: [PATCH] chore: fix specs for getFormData and convertToCsv --- src/utils/convertToCsv.ts | 6 +++++- src/utils/spec/getFormData.spec.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/convertToCsv.ts b/src/utils/convertToCsv.ts index 2e47d92..819b0b5 100644 --- a/src/utils/convertToCsv.ts +++ b/src/utils/convertToCsv.ts @@ -10,10 +10,14 @@ export const convertToCSV = ( tableName: string ) => { if (!data[tableName]) { - throw prefixMessage( + const error = prefixMessage( 'No table provided to be converted to CSV.', 'Error while converting to CSV. ' ) + + if (typeof error === 'string') throw new Error(error) + + throw error } const table = data[tableName] diff --git a/src/utils/spec/getFormData.spec.ts b/src/utils/spec/getFormData.spec.ts index 70954e3..e6fca36 100644 --- a/src/utils/spec/getFormData.spec.ts +++ b/src/utils/spec/getFormData.spec.ts @@ -10,8 +10,8 @@ describe('getFormData', () => { }) it('should return FormData if environment is not Node', () => { - const formDataMock = () => {} - ;(global as any).FormData = formDataMock + // Ensure FormData is globally available + ;(global as any).FormData = class FormData {} jest.spyOn(isNodeModule, 'isNode').mockImplementation(() => false)