Skip to content

test: unit tests useTodos Hook #1

@perzeuss

Description

@perzeuss

🧪 Add Unit Tests for useTodos Hook

📋 Overview

Create comprehensive unit tests for the useTodos custom hook to ensure all CRUD operations, error handling, and state management work correctly.

🎯 Acceptance Criteria

  • Test file hooks/use-todos.spec.ts is created
  • Tests cover all hook functions: addTodo, updateTodo, toggleTodo, deleteTodo
  • Tests verify loading states and error handling
  • API calls are properly mocked
  • Tests ensure state updates correctly after operations
  • All tests pass with npm test

🔧 Technical Requirements

  • Use Jest + React Testing Library
  • Mock fetch API calls
  • Test both success and error scenarios
  • TypeScript support for test files

🚫 Out of Scope

  • Integration tests with real API
  • Component integration testing
  • End-to-end testing scenarios
  • Performance testing
  • Testing Next.js specific features

📚 Resources

💡 Testing Tips

  • Test one function at a time
  • Always test both happy and unhappy cases
  • Use descriptive test names
  • Mock external dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions