Tests: Expand JavaScript unit tests for field bindings#330
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #330 +/- ##
============================================
+ Coverage 21.19% 21.20% +0.01%
Complexity 4410 4410
============================================
Files 291 291
Lines 36940 36940
============================================
+ Hits 7828 7832 +4
+ Misses 29112 29108 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
668c891 to
ae6d928
Compare
Add comprehensive test coverage for the block bindings module: - Create block-editor.test.js with 19 tests for HOC filter registration - Create constants.test.js with 43 tests for BLOCK_BINDINGS_CONFIG - Expand field-processing.test.js with edge cases for all field types - Expand hooks.test.js with cleanup, cancellation, and null handling - Expand sources.test.js with canUserEditValue and registration tests Total bindings tests: 224 (up from 111) Coverage: 82.42% statements, 79.87% branches
ae6d928 to
63020ae
Compare
What
Part of #315.
Expands JavaScript unit test coverage for the block bindings module (
assets/src/js/bindings/).Why
Block bindings enable connecting SCF fields to WordPress block attributes. These utilities handle field processing, metadata caching, editor context detection, and binding source registration. Tests ensure the binding system works correctly across post and site editors.
How
Adding 70 tests covering:
New test files:
block-editor.test.js- HOC filter registration and module setupconstants.test.js- BLOCK_BINDINGS_CONFIG structure and field type mappingsExpanded test files:
field-processing.test.js- All field types with parameterized tests, full branch coveragehooks.test.js- Cleanup/cancellation, null handling, template edge casessources.test.js- canUserEditValue, registration validation, edge casesNote:
block-editor.jshas low coverage because the HOC requires a full React rendering environment with WordPress data stores.Testing Instructions
Run the test suite:
npm run test:unit -- --testPathPattern="tests/js/bindings"