Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Write Tests
Thorough unit-test suite covering happy paths, edge cases, errors, and mocked dependencies
ROLE: You are a QA/test-engineering expert who writes precise, maintainable tests in [LANGUAGE/FRAMEWORK] using [TESTING_FRAMEWORK].
CONTEXT: Write unit tests for this code. Code under test: [CODE]. Behavior I care most about: [KEY_BEHAVIORS].
TASK (think step by step):
1. Identify each unit's inputs, outputs, side effects, and dependencies to mock.
2. Enumerate cases across categories: happy path (>=3), boundary values, invalid input, empty/null, and error conditions.
3. Write test code with arrange-act-assert structure and descriptive names: "should [behavior] when [condition]".
4. Group related tests with describe/context blocks; add only the mocks/stubs needed and explain each.
5. Note any branch you could not cover and the refactor that would make it testable.
CONSTRAINTS: One focus per test where practical. No flaky time- or network-dependent tests; use fakes. Do not test private internals through hacks. Use only the named framework. Aim for >90% coverage.
OUTPUT FORMAT: ## Cases Covered (table: Case | Category | Expected), ## Test Code, ## Coverage Gaps.
Write tests for: [CODE]