Files
office_translator/frontend/src/test/utils.test.ts
2026-03-07 11:42:58 +01:00

29 lines
817 B
TypeScript

import { describe, it, expect } from 'vitest';
import { getInitials } from '../app/dashboard/utils';
describe('getInitials', () => {
it('should return first two initials for full name', () => {
expect(getInitials('John Doe')).toBe('JD');
});
it('should return single initial for single name', () => {
expect(getInitials('Jane')).toBe('J');
});
it('should handle names with multiple spaces', () => {
expect(getInitials('John Jacob Jingleheimer Schmidt')).toBe('JJ');
});
it('should return ? for empty string', () => {
expect(getInitials('')).toBe('?');
});
it('should return ? for undefined', () => {
expect(getInitials(undefined as unknown as string)).toBe('?');
});
it('should handle lowercase names', () => {
expect(getInitials('john doe')).toBe('JD');
});
});