feat: tests adicionales data, UI funcional, build OK
This commit is contained in:
9
packages/core/vitest.config.ts
Normal file
9
packages/core/vitest.config.ts
Normal 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
1385
packages/data/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,13 +11,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc"
|
"build": "tsc",
|
||||||
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@toldo/core": "file:../core",
|
"@toldo/core": "file:../core",
|
||||||
"dexie": "^4.0.10"
|
"dexie": "^4.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "~6.0.3"
|
"fake-indexeddb": "^5.0.2",
|
||||||
|
"typescript": "~6.0.3",
|
||||||
|
"vitest": "^2.1.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
packages/data/src/__tests__/repositories.test.ts
Normal file
30
packages/data/src/__tests__/repositories.test.ts
Normal 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');
|
||||||
|
});
|
||||||
|
});
|
||||||
1
packages/data/tests/setup.ts
Normal file
1
packages/data/tests/setup.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import 'fake-indexeddb/auto';
|
||||||
9
packages/data/vitest.config.ts
Normal file
9
packages/data/vitest.config.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'node',
|
||||||
|
setupFiles: ['./tests/setup.ts'],
|
||||||
|
},
|
||||||
|
});
|
||||||
9
packages/services/vitest.config.ts
Normal file
9
packages/services/vitest.config.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'node',
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user