diff --git a/tests/integration/graphql/nonprofits-sorting.test.ts b/tests/integration/graphql/nonprofits-sorting.test.ts index b7c0557..8b98f78 100644 --- a/tests/integration/graphql/nonprofits-sorting.test.ts +++ b/tests/integration/graphql/nonprofits-sorting.test.ts @@ -125,7 +125,7 @@ beforeEach(async () => { project_contact_id: contactId, collab_contact_id: contactId, start_date: new Date('2024-06-01'), - end_date: new Date('2025-12-31'), + end_date: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365), project_status: 'ACTIVE', }, }); diff --git a/tests/unit/services/nonprofits.service.test.ts b/tests/unit/services/nonprofits.service.test.ts index 1dcd694..e7db959 100644 --- a/tests/unit/services/nonprofits.service.test.ts +++ b/tests/unit/services/nonprofits.service.test.ts @@ -58,7 +58,10 @@ describe('Nonprofit Service', () => { it('should return a single nonprofit when a valid ID is provided', async () => { const nonprofitId = '1'; const baseDate = new Date(); - const futureDate = new Date('2025-12-31'); + // get current time + const futureDate = new Date( + baseDate.getTime() + 1000 * 60 * 60 * 24 * 365 + ); // 1 year in the future const mockNonprofit = { nonprofit_id: '1', name: 'Test Nonprofit 1', @@ -85,7 +88,6 @@ describe('Nonprofit Service', () => { expect(result.nonprofit_id).toBe(mockNonprofit.nonprofit_id); expect(result.name).toBe(mockNonprofit.name); - expect(result.status).toBe('ACTIVE'); expect(prisma.nonprofits.findUnique).toHaveBeenCalledWith({ where: { nonprofit_id: nonprofitId }, include: { @@ -99,6 +101,8 @@ describe('Nonprofit Service', () => { }, }, }); + + expect(result.status).toBe('ACTIVE'); }); it('should throw NotFoundError if no nonprofit is found', async () => { @@ -166,7 +170,10 @@ describe('Nonprofit Service', () => { const nonprofitId = '1'; const updateData = { name: 'Updated Nonprofit Name' }; const baseDate = new Date(); - const futureDate = new Date('2025-12-31'); + // get current time + const futureDate = new Date( + baseDate.getTime() + 1000 * 60 * 60 * 24 * 365 + ); // 1 year in the future const updatedNonprofit = { nonprofit_id: '1', @@ -262,7 +269,9 @@ describe('Nonprofit Service', () => { describe('getNonprofitsWithFilters', () => { const baseDate = new Date('2024-01-01'); - const futureDate = new Date('2025-12-31'); + const now = new Date(); + // get current time + const futureDate = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365); // 1 year in the future const pastDate = new Date('2023-01-01'); it('should return all nonprofits with derived status when no filters are provided', async () => {