- Introduced CountryStep component for selecting the country during onboarding, affecting payment currency. - Updated FirstGroupStep to include country information. - Enhanced PaymentsProvider to manage payment states and renewals. - Created PaymentRow component for displaying individual payment details. - Implemented PaymentsView for listing and filtering payments by group and status. - Added API endpoints for fetching and creating payments, including batch processing. - Defined payment schemas for validation and data handling. - Updated GroupHeader and GroupDetailView to include charging functionality for group members.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { beforeEach, describe, expect, it, mock, vi } from 'bun:test';
|
|
|
|
const db = {
|
|
payment: {
|
|
updateMany: mock(),
|
|
},
|
|
};
|
|
|
|
mock.module('@/lib/prisma', () => ({
|
|
default: db,
|
|
getPrismaClient: mock(),
|
|
UnitOfWork: class {},
|
|
}));
|
|
|
|
import prisma from '@/lib/prisma';
|
|
import { MarkOverduePayments } from '@/modules/payments/jobs';
|
|
|
|
describe('mark overdue payments', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('marks PENDING payments whose due date passed more than a day ago', async () => {
|
|
prisma.payment.updateMany.mockResolvedValue({ count: 3 });
|
|
const now = new Date('2026-10-08T12:00:00.000Z');
|
|
|
|
const result = await new MarkOverduePayments({ now }).execute();
|
|
|
|
expect(result).toEqual({ marked: 3 });
|
|
expect(prisma.payment.updateMany).toHaveBeenCalledWith({
|
|
where: { status: 'PENDING', dueDate: { lt: new Date('2026-10-07T12:00:00.000Z') } },
|
|
data: { status: 'OVERDUE' },
|
|
});
|
|
});
|
|
|
|
it('leaves payments inside the grace period alone', async () => {
|
|
prisma.payment.updateMany.mockResolvedValue({ count: 0 });
|
|
|
|
const result = await new MarkOverduePayments({ now: new Date() }).execute();
|
|
|
|
expect(result).toEqual({ marked: 0 });
|
|
});
|
|
}); |