Skip to content

Commit

Permalink
test: make test for insertMany
Browse files Browse the repository at this point in the history
  • Loading branch information
miladezzat committed Feb 27, 2021
1 parent 6bce2cb commit abbf20d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/functionalty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,23 @@ describe('Functionality', () => {

expect(sortedArray).to.deep.eq([{ id: 8 }, { id: 7 }, { id: 3 }, { id: 1 }]);
});

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 binaryHeap = new BinaryHeap((x) => x.id, array.values());

const newArray = [{ id: 2 }];
const sortedArray = [];

binaryHeap.insertMany(newArray.values());
while (true) {
const x = binaryHeap.pop();
if (!x) break;

sortedArray.push(x);
}

expect(sortedArray).to.deep.eq([{ id: 8 }, { id: 7 }, { id: 3 }, { id: 2 }, { id: 1 }]);
});
});

0 comments on commit abbf20d

Please sign in to comment.