64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { EXERCISES } from '../../src/data/exercises.js';
|
|
import { EQUIPMENT, equipmentSlugFromName } from '../../src/data/equipment.js';
|
|
import { validateEquipmentSpec } from '../../src/lib/equipmentSpec.js';
|
|
|
|
/** Klucze mięśni obecne w katalogu (seed partii z docs/database/partia.csv). */
|
|
const KNOWN_MUSCLES = new Set([
|
|
'chest',
|
|
'back',
|
|
'shoulders',
|
|
'triceps',
|
|
'biceps',
|
|
'core',
|
|
'legs',
|
|
'glutes',
|
|
'forearms',
|
|
'calves',
|
|
]);
|
|
|
|
describe('katalog cwiczen (seed data)', () => {
|
|
it('ma unikalne slugi i niepuste nazwy', () => {
|
|
const slugs = EXERCISES.map((e) => e.slug);
|
|
expect(new Set(slugs).size).toBe(slugs.length);
|
|
for (const ex of EXERCISES) {
|
|
expect(ex.name.trim().length).toBeGreaterThan(0);
|
|
expect(ex.slug).toBe(ex.slug.trim().toLowerCase());
|
|
}
|
|
});
|
|
|
|
it('uzywa tylko znanych kluczy partii miesniowych', () => {
|
|
for (const ex of EXERCISES) {
|
|
expect(KNOWN_MUSCLES.has(ex.primaryMuscle)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('kazde cwiczenie wskazuje sprzet obecny w katalogu EQUIPMENT', () => {
|
|
for (const ex of EXERCISES) {
|
|
for (const slug of ex.equipment) {
|
|
const known =
|
|
EQUIPMENT.find((e) => e.slug === slug) ?? EQUIPMENT.find((e) => equipmentSlugFromName(e.name) === slug);
|
|
expect(known, `sprzet ${slug} (cwiczenie ${ex.slug})`).toBeDefined();
|
|
}
|
|
}
|
|
});
|
|
|
|
it('zawiera cwiczenia bez sprzetu (partia CSV: Brak)', () => {
|
|
expect(EXERCISES.some((e) => e.equipment.length === 0)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('katalog sprzetu (seed data)', () => {
|
|
it('ma unikalne nazwy i slugi', () => {
|
|
expect(new Set(EQUIPMENT.map((e) => e.name)).size).toBe(EQUIPMENT.length);
|
|
expect(new Set(EQUIPMENT.map((e) => e.slug)).size).toBe(EQUIPMENT.length);
|
|
});
|
|
|
|
it('ma spec zgodny z rodzajem (validateEquipmentSpec)', () => {
|
|
for (const eq of EQUIPMENT) {
|
|
const result = validateEquipmentSpec(eq.kind, eq.spec);
|
|
expect(result.ok, `spec dla ${eq.name} (${eq.kind})`).toBe(true);
|
|
}
|
|
});
|
|
});
|