From 1520533d110efae320801bde33770ac9fc1fee8a Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 12 Apr 2019 09:02:03 +0300 Subject: [PATCH] Fix issue #315. --- .../priority-queue/__test__/PriorityQueue.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/data-structures/priority-queue/__test__/PriorityQueue.test.js b/src/data-structures/priority-queue/__test__/PriorityQueue.test.js index e593965cc..2ffe4acb7 100644 --- a/src/data-structures/priority-queue/__test__/PriorityQueue.test.js +++ b/src/data-structures/priority-queue/__test__/PriorityQueue.test.js @@ -51,7 +51,7 @@ describe('PriorityQueue', () => { expect(priorityQueue.poll()).toBe(5); }); - it('should be possible to change priority of internal nodes', () => { + it('should be possible to change priority of head node', () => { const priorityQueue = new PriorityQueue(); priorityQueue.add(10, 1); @@ -59,6 +59,8 @@ describe('PriorityQueue', () => { priorityQueue.add(100, 0); priorityQueue.add(200, 0); + expect(priorityQueue.peek()).toBe(100); + priorityQueue.changePriority(100, 10); priorityQueue.changePriority(10, 20); @@ -68,7 +70,7 @@ describe('PriorityQueue', () => { expect(priorityQueue.poll()).toBe(10); }); - it('should be possible to change priority of head node', () => { + it('should be possible to change priority of internal nodes', () => { const priorityQueue = new PriorityQueue(); priorityQueue.add(10, 1); @@ -76,6 +78,8 @@ describe('PriorityQueue', () => { priorityQueue.add(100, 0); priorityQueue.add(200, 0); + expect(priorityQueue.peek()).toBe(100); + priorityQueue.changePriority(200, 10); priorityQueue.changePriority(10, 20);