Skip to content

Comments

test: add unit tests for unsetEmptyArray behavior#12939

Closed
kamja44 wants to merge 1 commit intoreact-hook-form:masterfrom
kamja44:test/unset-empty-array
Closed

test: add unit tests for unsetEmptyArray behavior#12939
kamja44 wants to merge 1 commit intoreact-hook-form:masterfrom
kamja44:test/unset-empty-array

Conversation

@kamja44
Copy link
Contributor

@kamja44 kamja44 commented Jul 6, 2025

Adds unit tests for the unsetEmptyArray utility function, which unsets a given path in an object if the value is an empty array (or falsy after compaction).

  • Tests that unset() is called when the target value is an empty array
  • Tests that unset() is not called when the array has truthy elements
  • Mocks unset() using Jest and verifies call behavior

This function is used internally to clean up empty values in form-related objects like errors or dirtyFields.
Having test coverage ensures correct conditional cleanup and improves confidence in future refactors.

@bluebill1049
Copy link
Member

could you please combine all your prs into one?

@kamja44
Copy link
Contributor Author

kamja44 commented Jul 6, 2025

Sure! I will close the existing three PRs(#12939, #12938, #12937) and create a new one that combines all three tasks(#12940).

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.

2 participants