Set up the complete project foundation for ClawX, a graphical AI assistant: - Electron main process with IPC handlers, menu, tray, and gateway management - React renderer with routing, layout components, and page scaffolding - Zustand state management for gateway, settings, channels, skills, chat, and cron - shadcn/ui components with Tailwind CSS and CSS variable theming - Build tooling with Vite, electron-builder, and TypeScript configuration - Testing setup with Vitest and Playwright - Development configurations (ESLint, Prettier, gitignore, env example)
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/**
|
|
* Utility Functions Tests
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { cn, formatRelativeTime, formatDuration, truncate } from '@/lib/utils';
|
|
|
|
describe('cn (class name merge)', () => {
|
|
it('should merge class names', () => {
|
|
expect(cn('foo', 'bar')).toBe('foo bar');
|
|
});
|
|
|
|
it('should handle conditional classes', () => {
|
|
expect(cn('base', true && 'active')).toBe('base active');
|
|
expect(cn('base', false && 'active')).toBe('base');
|
|
});
|
|
|
|
it('should merge tailwind classes correctly', () => {
|
|
expect(cn('px-2', 'px-4')).toBe('px-4');
|
|
expect(cn('text-red-500', 'text-blue-500')).toBe('text-blue-500');
|
|
});
|
|
});
|
|
|
|
describe('formatDuration', () => {
|
|
it('should format seconds only', () => {
|
|
expect(formatDuration(45)).toBe('45s');
|
|
});
|
|
|
|
it('should format minutes and seconds', () => {
|
|
expect(formatDuration(125)).toBe('2m 5s');
|
|
});
|
|
|
|
it('should format hours and minutes', () => {
|
|
expect(formatDuration(3725)).toBe('1h 2m');
|
|
});
|
|
});
|
|
|
|
describe('truncate', () => {
|
|
it('should not truncate short text', () => {
|
|
expect(truncate('Hello', 10)).toBe('Hello');
|
|
});
|
|
|
|
it('should truncate long text with ellipsis', () => {
|
|
expect(truncate('Hello World!', 8)).toBe('Hello...');
|
|
});
|
|
});
|