feat(test): add comprehensive test suite and testing infrastructure

- Add vitest configuration with coverage reporting
- Create test setup file with DOM mocks
- Add tests for state management, helpers, and tool configurations
- Update tsconfig and package.json for testing support
- Clean up unused comments and improve code style
This commit is contained in:
abdullahalam123
2025-10-12 17:47:08 +05:30
parent 3e52545a6c
commit 5e72d7ca2d
17 changed files with 2274 additions and 41 deletions

View File

@@ -0,0 +1,86 @@
import { describe, it, expect } from 'vitest';
import { singlePdfLoadTools, simpleTools, multiFileTools } from '@/js/config/pdf-tools';
describe('Tool Configuration Arrays', () => {
// --- Tests for singlePdfLoadTools ---
describe('singlePdfLoadTools', () => {
it('should be an array of non-empty strings', () => {
expect(Array.isArray(singlePdfLoadTools)).toBe(true);
expect(singlePdfLoadTools.length).toBeGreaterThan(0);
for (const tool of singlePdfLoadTools) {
expect(typeof tool).toBe('string');
expect(tool.length).toBeGreaterThan(0);
}
});
it('should have the correct number of tools', () => {
// This acts as a snapshot test to catch unexpected additions/removals.
expect(singlePdfLoadTools).toHaveLength(37);
});
it('should not contain any duplicate tools', () => {
const uniqueTools = new Set(singlePdfLoadTools);
expect(uniqueTools.size).toBe(singlePdfLoadTools.length);
});
});
// --- Tests for simpleTools ---
describe('simpleTools', () => {
it('should be an array of non-empty strings', () => {
expect(Array.isArray(simpleTools)).toBe(true);
expect(simpleTools.length).toBeGreaterThan(0);
simpleTools.forEach(tool => {
expect(typeof tool).toBe('string');
expect(tool.length).toBeGreaterThan(0);
});
});
it('should have the correct number of tools', () => {
expect(simpleTools).toHaveLength(5);
});
it('should not contain any duplicate tools', () => {
const uniqueTools = new Set(simpleTools);
expect(uniqueTools.size).toBe(simpleTools.length);
});
});
// --- Tests for multiFileTools ---
describe('multiFileTools', () => {
it('should be an array of non-empty strings', () => {
expect(Array.isArray(multiFileTools)).toBe(true);
expect(multiFileTools.length).toBeGreaterThan(0);
multiFileTools.forEach(tool => {
expect(typeof tool).toBe('string');
expect(tool.length).toBeGreaterThan(0);
});
});
it('should have the correct number of tools', () => {
expect(multiFileTools).toHaveLength(10);
});
it('should not contain any duplicate tools', () => {
const uniqueTools = new Set(multiFileTools);
expect(uniqueTools.size).toBe(multiFileTools.length);
});
});
// --- Cross-Category Uniqueness Test ---
describe('Uniqueness Across All Tool Categories', () => {
it('should ensure no tool exists in more than one category', () => {
const allTools = [
...singlePdfLoadTools,
...simpleTools,
...multiFileTools,
];
const uniqueTools = new Set(allTools);
// If the size of the Set is different from the length of the combined array,
// it means there was at least one duplicate tool across the categories.
expect(uniqueTools.size).toBe(allTools.length);
});
});
});