Skip to content

[27/N] Add unit tests for Stack, Queue, and Deque algorithms (Array and LL variants) - #118

Open
karkir0003 wants to merge 27 commits into
csvistool:masterfrom
karkir0003:karthik/kar-34-add-unit-tests-for-stack-queue-and-deque-algorithms-array-and-ll
Open

karkir0003 wants to merge 27 commits into
csvistool:masterfrom
karkir0003:karthik/kar-34-add-unit-tests-for-stack-queue-and-deque-algorithms-array-and-ll

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. ⬅️ [23/N] Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues) #114 (Add unit tests for algo util helpers (PriorityQueue, SkipListHeads, GraphValues))
  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)
  25. ⬅️ [25/N] Add unit tests for ArrayList algorithm #116 (Add unit tests for ArrayList algorithm)
  26. ⬅️ [26/N] Add unit tests for LinkedList, DoublyLinkedList, and CircularlyLinkedList algorithms #117 (Add unit tests for LinkedList, DoublyLinkedList, and CircularlyLinkedList algorithms)
  27. 👉 #CURRENT — Add unit tests for Stack, Queue, and Deque algorithms (Array and LL variants) (this PR)
  28. ➡️ [28/N] Add unit tests for BST, AVL, Heap, and SplayTree algorithms #119 (Add unit tests for BST, AVL, Heap, and SplayTree algorithms)

Addresses #93

Context

Adds comprehensive unit test coverage for the stack, queue, and deque algorithm visualizers across both array-backed and linked-list-backed implementations:
• StackArray.js: Array-backed stack with dynamic doubling resize.
• StackLL.js: Singly linked-list backed stack with Head pointer.
• QueueArray.js: Circular array-backed queue with modulo index wrap-around and unrolling resize.
• QueueLL.js: Linked-list backed queue with Head and Tail pointers.
• DequeArray.js: Double-ended circular array with front/back enqueue, dequeue, and shifted resize.
• DequeLL.js: Doubly linked-list backed deque with bidirectional Head and Tail manipulation.

Changes Made

• Introduced src/algo/__tests__/StackArray.test.js:
• Control registration (pushField, pushButton, popButton, randomButton, clearButton).
• push and pop operations, array doubling resize when full, capacity boundaries (MAX_SIZE), shaking invalid inputs.
• randomCallback, clearCallback, reset, and URL parameter deserialization (setURLData).

• Introduced src/algo/__tests__/StackLL.test.js:
• Linked list node instantiation, head pointer updates, and boundary shaking.
• Push to empty vs non-empty stack, pop multi-node vs single-node nullifying Head.
• randomCallback, clearAll, reset, and setURLData order verification.

• Introduced src/algo/__tests__/QueueArray.test.js:
• Circular array modulo indexing for enqueue ((front + size) % arraySize) and dequeue.
• Unrolling circular elements on dynamic doubling resize.
• Input validation, capacity limits, random generation, and parameter loading.

• Introduced src/algo/__tests__/QueueLL.test.js:
• Queue node linking with Head and Tail pointer maintenance.
• Dequeue operations handling single-element nullification and multi-element head advancement.
• Reset, clear, random routines, and URL data.

• Introduced src/algo/__tests__/DequeArray.test.js:
• Double-ended operations: addFirst, addLast, removeFirst, removeLast with circular modulo indexing.
• Specialized resize logic handling element shifting when expanding from front vs back.
• Edge cases (underflow shaking, empty inputs, capacity overflow), clear, and URL loading.

• Introduced src/algo/__tests__/DequeLL.test.js:
• Doubly linked list node creation, bidirectional pointer wiring (connectPrev/connectNext).
• Add/remove at front, back, and arbitrary index.
• Boundary handling (single-element deletion, empty deque checks), reset, clear, and URL parsing.

Test Plan

• Ran npm test -- --watchAll=false (all 6 new test suites pass, 86 unit tests passing).
• Ran npm run lint and npm run prettier (0 errors, 0 warnings).

@karkir0003
karkir0003 force-pushed the karthik/kar-34-add-unit-tests-for-stack-queue-and-deque-algorithms-array-and-ll branch from aac069d to 1f4f64a Compare October 3, 2026 16:28

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