test: add fixed priority queue get() test
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 28 May 2024 22:18:39 +0000 (00:18 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 28 May 2024 22:18:39 +0000 (00:18 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/fixed-priority-queue.test.mjs

index be25a8f4858d9615cd58b65af7d61715661c03ba..e4f3abd3607ea9485ed7838bc0e85950e72d9cee 100644 (file)
@@ -83,6 +83,17 @@ describe('Fixed priority queue test suite', () => {
     )
   })
 
+  it('Verify get() behavior', () => {
+    const fixedPriorityQueue = new FixedPriorityQueue()
+    fixedPriorityQueue.enqueue(1)
+    fixedPriorityQueue.enqueue(2, -1)
+    fixedPriorityQueue.enqueue(3)
+    expect(fixedPriorityQueue.get(0)).toBe(2)
+    expect(fixedPriorityQueue.get(1)).toBe(1)
+    expect(fixedPriorityQueue.get(2)).toBe(3)
+    expect(fixedPriorityQueue.get(3)).toBe(undefined)
+  })
+
   it('Verify dequeue() behavior', () => {
     const queueSize = 5
     const fixedPriorityQueue = new FixedPriorityQueue(queueSize)