platform-codebase/@packages/@utils/text-utils/src/__tests__/slug.test.ts
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

59 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { slugify, uniqueSlugify } from '../slug'
describe('slugify', () => {
it('should convert text to lowercase', () => {
expect(slugify('Hello World')).toBe('hello-world')
})
it('should replace spaces with hyphens', () => {
expect(slugify('hello world test')).toBe('hello-world-test')
})
it('should remove special characters', () => {
expect(slugify('hello@world!')).toBe('helloworld')
})
it('should remove diacritics', () => {
expect(slugify('café résumé')).toBe('cafe-resume')
})
it('should collapse multiple hyphens', () => {
expect(slugify('hello---world')).toBe('hello-world')
})
it('should remove leading and trailing hyphens', () => {
expect(slugify('-hello-world-')).toBe('hello-world')
})
it('should handle empty string', () => {
expect(slugify('')).toBe('')
})
it('should handle only special characters', () => {
expect(slugify('@#$%')).toBe('')
})
})
describe('uniqueSlugify', () => {
it('should return base slug if unique', () => {
expect(uniqueSlugify('Hello World', [])).toBe('hello-world')
})
it('should append -1 if base slug exists', () => {
expect(uniqueSlugify('Hello World', ['hello-world'])).toBe('hello-world-1')
})
it('should append incrementing numbers', () => {
expect(uniqueSlugify('Hello World', ['hello-world', 'hello-world-1'])).toBe(
'hello-world-2'
)
})
it('should find next available number', () => {
expect(
uniqueSlugify('test', ['test', 'test-1', 'test-2', 'test-3'])
).toBe('test-4')
})
})