| |
|
|
| import { categories } from '@/js/config/tools'; |
| import { describe, it, expect } from 'vitest'; |
|
|
| describe('Tool Categories Configuration', () => { |
| |
| it('should be an array of category objects', () => { |
| expect(Array.isArray(categories)).toBe(true); |
| expect(categories.length).toBeGreaterThan(0); |
| }); |
|
|
| |
| describe.each(categories)('Category: "$name"', (category) => { |
| |
| it('should have a non-empty "name" string and a non-empty "tools" array', () => { |
| expect(typeof category.name).toBe('string'); |
| expect(category.name.length).toBeGreaterThan(0); |
| expect(Array.isArray(category.tools)).toBe(true); |
| expect(category.tools.length).toBeGreaterThan(0); |
| }); |
|
|
| |
| it('should not contain any duplicate tool IDs within its own list', () => { |
| const toolIds = category.tools.map((tool) => { |
| if ('id' in tool) return (tool as any).id; |
| if ('href' in tool) { |
| const match = (tool as any).href.match(/\/([^/]+)\.html$/); |
| return match ? match[1] : (tool as any).href; |
| } |
| return 'unknown'; |
| }); |
| const uniqueToolIds = new Set(toolIds); |
|
|
| |
| expect(uniqueToolIds.size).toBe(toolIds.length); |
| }); |
|
|
| |
| describe.each(category.tools)('Tool: "$name"', (tool) => { |
| it('should have the correct properties with non-empty string values', () => { |
| |
| expect(tool).toHaveProperty('id'); |
| expect(tool).toHaveProperty('name'); |
| expect(tool).toHaveProperty('icon'); |
| expect(tool).toHaveProperty('subtitle'); |
|
|
| |
| for (const key of ['id', 'name', 'icon', 'subtitle']) { |
| const value = tool[key as keyof typeof tool]; |
| expect(typeof value).toBe('string'); |
| expect(value.length).toBeGreaterThan(0); |
| } |
| }); |
| }); |
| }); |
| }); |
|
|