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,9 @@
import { defineConfig } from 'vitest/config';
import path from 'path';
export default defineConfig({
test: {
globals: true,
environment: 'node',
},
});

1385
packages/data/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -11,13 +11,16 @@
}
},
"scripts": {
"build": "tsc"
"build": "tsc",
"test": "vitest"
},
"dependencies": {
"@toldo/core": "file:../core",
"dexie": "^4.0.10"
},
"devDependencies": {
"typescript": "~6.0.3"
"fake-indexeddb": "^5.0.2",
"typescript": "~6.0.3",
"vitest": "^2.1.8"
}
}

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');
});
});

View File

@@ -0,0 +1 @@
import 'fake-indexeddb/auto';

View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
setupFiles: ['./tests/setup.ts'],
},
});

View File

@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config';
import path from 'path';
export default defineConfig({
test: {
globals: true,
environment: 'node',
},
});