File size: 893 Bytes
00b4e55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * Tests for validators.
 * @module validatorTests
 */

import { describe, it, expect } from 'vitest';
import { userCreateSchema } from '../../src/utils/validators';

describe('userCreateSchema', () => {
  it('should accept valid user data', () => {
    const valid = {
      email: 'test@example.com',
      password: 'SecurePass123',
      name: 'Test User',
    };
    expect(() => userCreateSchema.parse(valid)).not.toThrow();
  });

  it('should reject invalid email', () => {
    const invalid = {
      email: 'not-an-email',
      password: 'SecurePass123',
    };
    expect(() => userCreateSchema.parse(invalid)).toThrow('Invalid email format');
  });

  it('should reject short password', () => {
    const invalid = {
      email: 'test@example.com',
      password: 'short',
    };
    expect(() => userCreateSchema.parse(invalid)).toThrow('at least 8 characters');
  });
});