Renamed Student to Attendee

This commit is contained in:
Jose Selesan
2026-09-17 18:58:00 -03:00
parent e8bca3a5ae
commit fa30fe2cff
22 changed files with 120 additions and 104 deletions

View File

@@ -3,7 +3,7 @@ import { Hono } from 'hono';
mock.module('@/lib/prisma', () => ({
default: {
student: {
attendee: {
findMany: mock(),
count: mock(),
},
@@ -13,13 +13,13 @@ mock.module('@/lib/prisma', () => ({
}));
import prisma from '@/lib/prisma';
import { studentsRoutes } from '@/modules/students';
import { attendeesRoutes } from '@/modules/attendees';
const app = new Hono();
app.route('/students', studentsRoutes);
app.route('/attendees', attendeesRoutes);
const student = {
id: 'student-1',
const attendee = {
id: 'attendee-1',
groupId: 'group-1',
fullName: 'Ana Pérez',
email: 'ana@example.com',
@@ -31,41 +31,41 @@ const student = {
updatedAt: new Date('2026-08-01T10:00:00.000Z'),
};
describe('students routes', () => {
describe('attendees routes', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('lists students with pagination', async () => {
prisma.student.findMany.mockResolvedValue([student]);
prisma.student.count.mockResolvedValue(21);
it('lists attendees with pagination', async () => {
prisma.attendee.findMany.mockResolvedValue([attendee]);
prisma.attendee.count.mockResolvedValue(21);
const res = await app.request('/students?page=2&pageSize=10');
const res = await app.request('/attendees?page=2&pageSize=10');
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
data: [
{
...student,
createdAt: student.createdAt.toISOString(),
updatedAt: student.updatedAt.toISOString(),
...attendee,
createdAt: attendee.createdAt.toISOString(),
updatedAt: attendee.updatedAt.toISOString(),
},
],
pagination: { page: 2, pageSize: 10, total: 21, totalPages: 3 },
});
expect(prisma.student.findMany).toHaveBeenCalledWith({
expect(prisma.attendee.findMany).toHaveBeenCalledWith({
skip: 10,
take: 10,
orderBy: { createdAt: 'desc' },
});
expect(prisma.student.count).toHaveBeenCalledWith();
expect(prisma.attendee.count).toHaveBeenCalledWith();
});
it('uses default pagination', async () => {
prisma.student.findMany.mockResolvedValue([]);
prisma.student.count.mockResolvedValue(0);
prisma.attendee.findMany.mockResolvedValue([]);
prisma.attendee.count.mockResolvedValue(0);
const res = await app.request('/students');
const res = await app.request('/attendees');
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
@@ -75,7 +75,7 @@ describe('students routes', () => {
});
it('rejects invalid pagination query parameters', async () => {
const res = await app.request('/students?page=0&pageSize=25');
const res = await app.request('/attendees?page=0&pageSize=25');
expect(res.status).toBe(400);
expect(await res.json()).toMatchObject({ status: 400, title: 'Bad Request' });

View File

@@ -20,8 +20,8 @@ app.route('/payments', paymentsRoutes);
const payment = {
id: 'payment-1',
groupId: 'group-1',
studentId: 'student-1',
groupId: 'group-1',
attendeeId: 'attendee-1',
amount: { toString: () => '150.50' } as { toString(): string },
currency: 'MXN',
status: 'pending',
@@ -47,8 +47,8 @@ describe('payments routes', () => {
data: [
{
id: 'payment-1',
groupId: 'group-1',
studentId: 'student-1',
groupId: 'group-1',
attendeeId: 'attendee-1',
amount: 150.5,
currency: 'MXN',
status: 'pending',

View File

@@ -35,7 +35,7 @@ describe('session auth', () => {
expect(isPublicApiRequest('GET', '/api/v1/health')).toBe(true);
expect(isPublicApiRequest('POST', '/api/v1/auth/sign-in/email')).toBe(true);
expect(isPublicApiRequest('GET', '/api/v1/groups')).toBe(false);
expect(isPublicApiRequest('GET', '/api/v1/students')).toBe(false);
expect(isPublicApiRequest('GET', '/api/v1/attendees')).toBe(false);
});
it('allows public requests without a session', async () => {