Skip to content

test: Add comprehensive unit tests for WhenAnyTask#162

Merged
YunchuWang merged 1 commit intomainfrom
copilot-finds/test/when-any-task-coverage
Mar 11, 2026
Merged

test: Add comprehensive unit tests for WhenAnyTask#162
YunchuWang merged 1 commit intomainfrom
copilot-finds/test/when-any-task-coverage

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

Summary

Add comprehensive unit test coverage for WhenAnyTask, which previously had zero tests.

Closes #158

Changes

  • Add when-any-task.spec.ts with tests covering:
    • Empty input validation
    • Basic completion on first child
    • Result semantics (returns completed child Task)
    • Child failure behavior
    • Idempotent completion guard
    • Pre-completed/pre-failed children
    • Parent composite task notification chain
    • Single-child edge case

WhenAnyTask is a core public API (exported via whenAny()) with zero test
coverage, despite its sibling WhenAllTask having 7 tests. This adds 11
unit tests covering:
- Empty input validation
- Basic completion on first child
- Result is the completed child Task itself
- Child failure behavior (WhenAny does not propagate, returns failed task)
- Idempotent completion guard (subsequent completions ignored)
- Pre-completed children (immediate completion in constructor)
- Pre-failed children
- Multiple pre-completed children (first wins)
- Single-child edge case
- Parent composite task notification
- No completion when no children have completed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 18:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing unit test coverage for the core WhenAnyTask composite task, ensuring its completion semantics and key edge-cases are protected against regressions (closes #158).

Changes:

  • Introduces a new Jest spec file covering WhenAnyTask validation, completion, failure-result semantics, idempotency, and pre-completed/pre-failed children.
  • Adds a regression-style test that validates parent composite notification behavior via WhenAllTask.

You can also share your feedback on Copilot code review. Take the survey.

@YunchuWang YunchuWang merged commit 843c774 into main Mar 11, 2026
32 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/test/when-any-task-coverage branch March 11, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Missing Tests: WhenAnyTask has zero test coverage

4 participants