feat: tests adicionales data, UI funcional, build OK

This commit is contained in:
mono
2026-10-24 21:16:13 -05:00
parent df3838c2f3
commit 6d48f4a839
7 changed files with 1449 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { db } from '../db/schema';
import { ProductorRepository } from '../repositories/ProductorRepository';
import { ProductoRepository } from '../repositories/ProductoRepository';
describe('Repositories', () => {
const prodRepo = new ProductorRepository();
const prodRepoProd = new ProductoRepository();
beforeEach(async () => {
await db.delete();
await db.open();
});
it('crea y obtiene productor', async () => {
const p = { id: '1', nombre: 'Productor A', activo: true, createdAt: new Date() };
await prodRepo.create(p);
const all = await prodRepo.getAll();
expect(all.length).toBe(1);
expect(all[0].nombre).toBe('Productor A');
});
it('crea producto por productor y previene duplicado mismo nombre', async () => {
const prod = { id: 'p1', nombre: 'P1', activo: true, createdAt: new Date() };
await prodRepo.create(prod);
const producto = { id: 'pr1', productorId: 'p1', nombrePresentacion: 'Café 250gr', precioUnitario: 1000, activo: true, createdAt: new Date() };
await prodRepoProd.create(producto);
await expect(prodRepoProd.create({ ...producto, id: 'pr2' })).rejects.toThrow('Ya existe un producto con ese nombre para este productor');
});
});