Skip to content

[23/N] Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues) - #114

Open
karkir0003 wants to merge 23 commits into
csvistool:masterfrom
karkir0003:karthik/kar-30-add-unit-tests-for-algo-util-helpers
Open

karkir0003 wants to merge 23 commits into
csvistool:masterfrom
karkir0003:karthik/kar-30-add-unit-tests-for-algo-util-helpers

Conversation

@karkir0003

@karkir0003 karkir0003 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🥞 Stack

  1. ⬅️ [1/N] Update CI to run frontend unit tests #91 (Update CI to run frontend unit tests)
  2. ⬅️ [2/N] Configure React Testing Library and Setup Tests #92 (Configure React Testing Library and Setup Tests)
  3. ⬅️ [3/N] Add unit tests for SideButton component #94 (Add unit tests for SideButton component)
  4. ⬅️ [4/N] Add unit tests for SearchFilter component #95 (Add unit tests for SearchFilter component)
  5. ⬅️ [5/N] Add unit tests for Header and Footer components #96 (Add unit tests for Header and Footer components)
  6. ⬅️ [6/N] Add unit tests for Blob mascot component #97 (Add unit tests for Blob mascot component)
  7. ⬅️ [7/N] Add unit tests for AboutScreen screen #98 (Add unit tests for AboutScreen screen)
  8. ⬅️ [8/N] Add integration tests for HomeScreen screen #99 (Add integration tests for HomeScreen screen)
  9. ⬅️ [9/N] Add unit tests for AlgorithmNotFound404 component #100 (Add unit tests for AlgorithmNotFound404 component)
  10. ⬅️ [10/N] Add integration tests for AlgoScreen screen #101 (Add integration tests for AlgoScreen screen)
  11. ⬅️ [11/N] Add unit tests for ModalSidebarSectionTab component #102 (Add unit tests for ModalSidebarSectionTab component)
  12. ⬅️ [12/N] Add unit tests for BigOModal component #103 (Add unit tests for BigOModal component)
  13. ⬅️ [13/N] Add unit tests for Pseudocode component #104 (Add unit tests for Pseudocode component)
  14. ⬅️ [14/N] Add unit and integration tests for AlgoSection component #105 (Add unit and integration tests for AlgoSection component)
  15. ⬅️ [15/N] Add unit and integration tests for root App component #106 (Add unit and integration tests for root App component)
  16. ⬅️ [16/N] Add unit tests for animation events and undo functions #107 (Add unit tests for animation events and undo functions)
  17. ⬅️ [17/N] Add unit tests for AnimatedObject, AnimatedCircle, and AnimatedHighlightCircle #108 (Add unit tests for AnimatedObject, AnimatedCircle, and AnimatedHighlightCircle)
  18. ⬅️ [18/N] Add unit tests for AnimatedRectangle, AnimatedLabel, and AnimatedLine #109 (Add unit tests for AnimatedRectangle, AnimatedLabel, and AnimatedLine)
  19. ⬅️ [19/N] Add unit tests for AnimatedLinkedListNode, AnimatedDoublyLinkedListNode, and AnimatedCircularlyLinkedListNode #110 (Add unit tests for AnimatedLinkedListNode, AnimatedDoublyLinkedListNode, and AnimatedCircularlyLinkedListNode)
  20. ⬅️ [20/N] Add unit tests for AnimatedBTreeNode and AnimatedSkipListNode #111 (Add unit tests for AnimatedBTreeNode and AnimatedSkipListNode)
  21. ⬅️ [21/N] Add unit tests for ObjectManager #112 (Add unit tests for ObjectManager)
  22. ⬅️ [22/N] Add unit tests for AnimationMain #113 (Add unit tests for AnimationMain)
  23. 👉 #CURRENT — Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues) (this PR)
  24. ➡️ [24/N] Add unit tests for base Algorithm class and control bar helpers #115 (Add unit tests for base Algorithm class and control bar helpers)

Addresses #93

Context

Adds unit test coverage for the standalone utility modules located in src/algo/util/, which power data structures and graph algorithms throughout the visualizer:

  • PriorityQueue.js: Min-priority queue implementation used in Dijkstra's, Prim's, and Huffman coding animations.
  • SkipListHeads.js: Seed head-count sequence used for reproducible SkipList tower animations.
  • GraphValues.js: Graph topology definitions, logical coordinates, curve layouts, color palettes, and adjacency matrices for BFS/DFS, Dijkstra's, Floyd-Warshall, Prim's, and Kruskal's algorithms.

Changes Made

• Introduced src/algo/util/__tests__/PriorityQueue.test.js covering:
• Queue initialization (backingArray, size(), getIDs()).
• Priority sorting ascending (lower priority dequeued first).
• Tie-breaking logic:
• Scalar data comparison.
• Array-based data comparison on first index (a[0][0] - b[0][0]).
• Array-based data comparison on secondary index (a[0][1] - b[0][1]).
• Dequeue payload formatting ([data, id]) and dynamic size tracking.
• Introduced src/algo/util/__tests__/SkipListHeads.test.js covering:
• Array structure and length validation (1000 items).
• Value bounding ([0, 4] range validation).
• Introduced src/algo/util/__tests__/GraphValues.test.js covering:
• Small graph (8 vertices) and large graph (18 vertices) logical coordinate arrays (SMALL_X_POS_LOGICAL, SMALL_Y_POS_LOGICAL, LARGE_X_POS_LOGICAL, LARGE_Y_POS_LOGICAL).
• Allowance boolean matrices and curve matrices (SMALL_ALLLOWED, LARGE_ALLOWED, SMALL_CURVE, LARGE_CURVE).
• Adjacency list matrices (BFS_DFS_ADJ_LIST, DIJKSTRAS_ADJ_LIST, FLOYD_ADJ_LIST, PRIMS_KRUSKALS_ADJ_LIST, LARGE_ADJ_LIST).
• Disjoint set color palette verification (KRUSKALS_DS_COLORS).

Test Plan

• Ran npm test -- --watchAll=false (all 32 test suites pass).
• Ran npm run lint and npm run prettier.
• Verified 100% statement, function, and branch coverage on all files in src/algo/util/.

This branch has not been deployed

No deployments
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