Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/graphql/nonprofits-sorting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
});
Expand Down
17 changes: 13 additions & 4 deletions tests/unit/services/nonprofits.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand All @@ -99,6 +101,8 @@ describe('Nonprofit Service', () => {
},
},
});

expect(result.status).toBe('ACTIVE');
});

it('should throw NotFoundError if no nonprofit is found', async () => {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 () => {
Expand Down