feat: add tests for normalizeName and RecipesService methods, including unit conversion and alias normalization

This commit is contained in:
Nils-Johan Gynther
2026-04-16 19:22:14 +02:00
parent 1b9df4d20d
commit 9292e30abc
6 changed files with 305 additions and 9 deletions
@@ -0,0 +1,42 @@
import { normalizeName } from './normalize-name';
describe('normalizeName', () => {
it('gör om till gemener', () => {
expect(normalizeName('Kycklingfilé')).toBe('kycklingfile');
});
it('tar bort svenska diakritiska tecken', () => {
expect(normalizeName('åäö')).toBe('aao');
expect(normalizeName('ÅÄÖ')).toBe('aao');
});
it('tar bort mellanslag', () => {
expect(normalizeName('rökt paprikapulver')).toBe('roktpaprikapulver');
});
it('tar bort inledande och avslutande mellanslag', () => {
expect(normalizeName(' lax ')).toBe('lax');
});
it('tar bort specialtecken', () => {
expect(normalizeName('Curry (mild)')).toBe('currymild');
});
it('hanterar siffror', () => {
expect(normalizeName('Omega-3')).toBe('omega3');
});
it('hanterar tom sträng', () => {
expect(normalizeName('')).toBe('');
});
it('hanterar sträng med bara mellanslag', () => {
expect(normalizeName(' ')).toBe('');
});
it('normaliserar accenter korrekt', () => {
expect(normalizeName('Fläskfilé')).toBe('flaskfile');
expect(normalizeName('Gräddfil')).toBe('graddfil');
expect(normalizeName('Rödlök')).toBe('rodlok');
});
});