Skip to content

test: unit tests useTodos Hook#1

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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