# Test Suite Documentation

## Overview

This directory contains comprehensive unit and integration tests for all JavaScript modules in the Todozi project.

## Test Structure

- `__tests__/` - Main test files
  - `*.test.js` - Individual module tests
  - `integration.test.js` - Integration tests
- `__tests__/helpers/` - Test utilities and fixtures
  - `testUtils.js` - Common test utilities
  - `mocks.js` - Shared mocks
- `__tests__/__mocks__/` - Jest mocks

## Running Tests

```bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Run tests with verbose output
npm run test:verbose
```

## Test Files

Each source file has a corresponding test file:
- `models.test.js` - Tests for data models (Priority, Status, Task, Project, etc.)
- `error.test.js` - Tests for error handling
- `storage.test.js` - Tests for file system operations
- `api.test.js` - Tests for API key management
- `search.test.js` - Tests for search functionality
- `cli.test.js` - Tests for command-line interface
- `server.test.js` - Tests for HTTP server
- And more...

## Coverage Goals

Target coverage: >80% for all files.

## Writing New Tests

1. Create a test file matching the pattern: `__tests__/[module].test.js`
2. Import the module and test utilities
3. Write unit tests for individual functions/classes
4. Write integration tests for workflows
5. Use test fixtures from `helpers/testUtils.js`
6. Mock external dependencies appropriately

