add: comprehensive TDD test infrastructure

- Add Vitest + jsdom testing framework
- Create unit tests for engine.js and generator.js
- Add integration tests for end-to-end workflows
- Include test utilities and setup helpers
- Document testing approach in TESTING.md
- Document all dependencies in DEPENDS.md
- Add Makefile with test targets and dev workflow

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-18 23:36:22 +01:00
parent eeebdd72d5
commit 2090e372bd
10 changed files with 1320 additions and 0 deletions

39
test/setup.js Normal file
View File

@@ -0,0 +1,39 @@
// Test setup file for Vitest
import { vi } from 'vitest'
// Mock PapaParse (since it's loaded via CDN)
global.Papa = {
parse: vi.fn()
}
// Mock fetch for loading files
global.fetch = vi.fn()
// Setup DOM helpers
beforeEach(() => {
// Reset DOM
document.head.innerHTML = ''
document.body.innerHTML = ''
// Clear all mocks
vi.clearAllMocks()
})
// Create helper functions for DOM setup
export const createMockElement = (tagName, attributes = {}) => {
const element = document.createElement(tagName)
Object.entries(attributes).forEach(([key, value]) => {
element.setAttribute(key, value)
})
return element
}
export const setupBasicDOM = () => {
document.body.innerHTML = `
<div id="projectName"></div>
<div id="projectSubtitle"></div>
<div id="viewer"></div>
<link id="dynamicCss" rel="stylesheet" href="">
<button id="downloadSvg"></button>
`
}