diff --git a/tests/functionalty.spec.ts b/tests/functionalty.spec.ts index 36324cf..848d9d2 100644 --- a/tests/functionalty.spec.ts +++ b/tests/functionalty.spec.ts @@ -5,7 +5,8 @@ import { MaxHeap, MinHeap } from '../src/index'; describe('Functionality', () => { it('it works as a max heap', () => { - const maxHeap = new MaxHeap((x) => x, [1, 7, 5, 8].values()); + const maxHeap = new MaxHeap((x) => x); + maxHeap.insertMany([1, 7, 5, 8].values()); const sortedArray = []; @@ -20,7 +21,8 @@ describe('Functionality', () => { }); it('it works as a min heap', () => { - const minHeap = new MinHeap((x) => x, [1, 7, 5, 8].values()); + const minHeap = new MinHeap((x) => x); + minHeap.insertMany([1, 7, 5, 8].values()); const sortedArray = []; @@ -35,7 +37,8 @@ describe('Functionality', () => { }); it('it works with sets', () => { - const maxHeap = new MaxHeap((x) => x, new Set([1, 7, 5, 8]).values()); + const maxHeap = new MaxHeap((x) => x); + maxHeap.insertMany([1, 7, 5, 8].values()); const sortedArray = []; @@ -57,7 +60,8 @@ describe('Functionality', () => { map.set(5, '5'); map.set(8, '8'); - const maxHeap = new MaxHeap((x) => x, map.keys()); + const maxHeap = new MaxHeap((x) => x); + maxHeap.insertMany(map.keys()); const sortedArray = []; @@ -74,10 +78,8 @@ describe('Functionality', () => { it('it works with complex objects given the right extractor', () => { const array = [{ id: 1 }, { id: 7 }, { id: 3 }, { id: 8 }]; - const maxHeap = new MaxHeap( - (x) => x.id, - array.values(), - ); + const maxHeap = new MaxHeap((x:{id:number}) => x.id); + maxHeap.insertMany(array.values()); const sortedArray = []; @@ -94,7 +96,8 @@ describe('Functionality', () => { it('it works with complex objects given the right extractor and use insert many for bulk', () => { const array = [{ id: 1 }, { id: 7 }, { id: 3 }, { id: 8 }]; - const maxHeap = new MaxHeap((x) => x.id, array.values()); + const maxHeap = new MaxHeap((x:{id:number}) => x.id); + maxHeap.insertMany(array.values()); const newArray = [{ id: 2 }]; const sortedArray = [];