Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: slightly better tests for useResizeObserver (#608)
### **PR Type** tests, enhancement ___ ### **Description** - Added a new mock implementation for `ResizeObserver` to facilitate testing. - Improved test coverage for the `useResizeObserver` hook, including testing observer disconnection. - Simplified conditional checks in `useResizeObserver` using `c8 ignore next` for better code coverage handling. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>ResizeObserver.ts</strong><dd><code>Add mock implementation for ResizeObserver</code> </dd></summary> <hr> packages/ui-hooks/src/hooks/__tests__/__mocks__/ResizeObserver.ts <li>Added a mock implementation for <code>ResizeObserver</code>.<br> <li> Implemented methods to simulate resize events.<br> <li> Utilized <code>vitest</code> for mocking functions.<br> </details> </td> <td><a href="https://github.com/aversini/ui-components/pull/608/files#diff-cd7fcfea89952737da719c2e7c1e5503ac41f7ca30268423d53384e84846fd9b">+69/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>useResizeObserver.test.tsx</strong><dd><code>Improve and expand tests for useResizeObserver</code> </dd></summary> <hr> packages/ui-hooks/src/hooks/__tests__/useResizeObserver.test.tsx <li>Replaced inline <code>ResizeObserverMock</code> with imported mock.<br> <li> Enhanced test cases for <code>useResizeObserver</code>.<br> <li> Added test for observer disconnection on unmount.<br> </details> </td> <td><a href="https://github.com/aversini/ui-components/pull/608/files#diff-817c498322b1d9ec6ea8df205b7893101d4b89f74fb9e6ef998d09c64931389d">+31/-87</a> </td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>useResizeObserver.ts</strong><dd><code>Simplify conditional checks and ensure cleanup</code> </dd></summary> <hr> packages/ui-hooks/src/hooks/useResizeObserver.ts <li>Simplified conditional checks using <code>c8 ignore next</code>.<br> <li> Ensured observer disconnects on component unmount.<br> </details> </td> <td><a href="https://github.com/aversini/ui-components/pull/608/files#diff-bb3ddb329d4b3f6fd8a1e761a789d33ba9e6b3556d42068d3928b15ff426bda1">+3/-4</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
- Loading branch information