From 5e75378280ebab3438d04b56b8ebb823f3c4649a Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 30 Mar 2018 08:07:13 +0300 Subject: [PATCH] Add Heap. --- src/data-structures/heap/__test__/MinHeap.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/data-structures/heap/__test__/MinHeap.test.js b/src/data-structures/heap/__test__/MinHeap.test.js index 64963de2..99c8861c 100644 --- a/src/data-structures/heap/__test__/MinHeap.test.js +++ b/src/data-structures/heap/__test__/MinHeap.test.js @@ -34,20 +34,24 @@ describe('MinHeap', () => { minHeap.add(5); minHeap.add(3); minHeap.add(10); + minHeap.add(11); minHeap.add(1); - expect(minHeap.toString()).toBe('1,3,10,5'); + expect(minHeap.toString()).toBe('1,3,10,11,5'); expect(minHeap.poll()).toBe(1); - expect(minHeap.toString()).toBe('3,5,10'); + expect(minHeap.toString()).toBe('3,5,10,11'); expect(minHeap.poll()).toBe(3); - expect(minHeap.toString()).toBe('5,10'); + expect(minHeap.toString()).toBe('5,11,10'); expect(minHeap.poll()).toBe(5); - expect(minHeap.toString()).toBe('10'); + expect(minHeap.toString()).toBe('10,11'); expect(minHeap.poll()).toBe(10); + expect(minHeap.toString()).toBe('11'); + + expect(minHeap.poll()).toBe(11); expect(minHeap.toString()).toBe(''); expect(minHeap.poll()).toBeNull();