Skip to content

Comments

test: add unit tests for shouldRenderFormState and group root subscriber cases#12938

Closed
kamja44 wants to merge 1 commit intoreact-hook-form:masterfrom
kamja44:test/should-render-form-state
Closed

test: add unit tests for shouldRenderFormState and group root subscriber cases#12938
kamja44 wants to merge 1 commit intoreact-hook-form:masterfrom
kamja44:test/should-render-form-state

Conversation

@kamja44
Copy link
Contributor

@kamja44 kamja44 commented Jul 6, 2025

Adds comprehensive unit tests for the internal utility function shouldRenderFormState.
This ensures correctness of form state reactivity based on subscription flags and root-level validation mode.

  • Adds test cases for:
    • Empty formState returns true
    • Changed keys exceed subscription length
    • Matching subscribed keys (including isRoot logic)
  • Covers all logical branches (including default return, VALIDATION_MODE.all)
  • Groups root subscriber–specific scenarios under a dedicated describe block for clarity

This logic determines whether a form should re-render based on field-level or global state subscription.
Having full test coverage prevents subtle bugs and provides confidence in future refactors.

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.

1 participant