Add validación y slug del signup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
25
mvp/b2c/tests/validation/signup.test.ts
Normal file
25
mvp/b2c/tests/validation/signup.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { signupSchema, slugify } from '@/lib/validation/signup';
|
||||
|
||||
describe('signupSchema', () => {
|
||||
it('acepta un alta válida y normaliza email a minúsculas', () => {
|
||||
const r = signupSchema.safeParse({
|
||||
nombre: 'Ana', email: 'Ana@X.com', empresa: 'Reformas Ana',
|
||||
provincia: 'Madrid', password: 'Segura2026', optInMarketing: 'on',
|
||||
});
|
||||
expect(r.success).toBe(true);
|
||||
if (r.success) expect(r.data.email).toBe('ana@x.com');
|
||||
});
|
||||
|
||||
it('rechaza email inválido y contraseña corta', () => {
|
||||
expect(signupSchema.safeParse({
|
||||
nombre: 'Ana', email: 'no-mail', empresa: 'X', provincia: 'Madrid', password: '123',
|
||||
}).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('slugify', () => {
|
||||
it('genera slug url-safe sin acentos', () => {
|
||||
expect(slugify('Reformas Ándalus, S.L.')).toBe('reformas-andalus-s-l');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user