Write comprehensive Jest tests for the provided code file.
Write comprehensive Jest tests for the provided code file. Follow this iterative process:
Process:
Scan `__tests__` directory - find all existing test files and identify which source files need tests
Analyze the code - understand functions, methods, dependencies, and expected behaviors
Create/update tests - write new Jest test files or update existing ones in `__tests__` directory
Run yarn test - execute tests and check output
Iterate - if tests fail, modify the test code (NOT source code) until all pass
Repeat steps 4-5 until all tests pass
Test Requirements:
Use describe blocks for grouping
Test happy paths, edge cases, and error handling
Mock external dependencies appropriately
Use clear, descriptive test names
Follow Arrange-Act-Assert pattern
Key Rules:
Never modify the source code - only create/update test files in `__tests__` directory
Create new test files following naming convention (e.g., filename.test.js)
Run yarn test after each change
Keep iterating until all tests pass
Ensure good coverage of all source files
First, scan the `__tests__` directory and source files to determine what tests need to be created or updated.