Add white-box unit tests for collision modules #464
+110
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is attempting to solve following
Issue #352
WHAT I Have Done
-> Added complete white-box unit tests for the collision system.
-> Covered all main modules: Brute, QuadTree, and utils.
-> Ensured each module is tested under different collision scenarios.
-> Followed the required folder structure for the collision tests.
WHY I Did This
-> Collision detection is a core part of Music Blocks v4.
-> Tests ensure correctness, stability, and predictable behavior.
-> Helps avoid regressions in future updates.
-> Supports future contributors with a reliable foundation.
Summary of Changes:
Added tests for Brute.ts:
• Overlapping object detection
• Non-overlapping object detection
Added tests for QuadTree.ts:
• Object insertion
• Collision detection within regions
Added tests for utils/index.ts:
• Rectangle–rectangle collision
• Circle–circle collision
Organized files as follows:

📦collision
┣ 📂spec
┃ ┣ 📜Brute.spec.ts
┃ ┣ 📜index.spec.ts
┃ ┗ 📜QuadTree.spec.ts
┣ 📂utils
┃ ┗ 📜index.ts
┣ 📜Brute.ts
┣ 📜index.ts
┗ 📜QuadTree.ts
Please let me know if any improvements or additional test cases are required.
Thank you!