Skip to content

Commit 5a2b51e

Browse files
committed
test: add cases for _topN_heap to handle edge scenarios
1 parent 9587fb4 commit 5a2b51e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/heap-async/heap-async-private-methods.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ describe('HeapAsync private', function () {
118118
expect(await heap._topN_heap(slice)).toEqual(top.slice(0, slice));
119119
}
120120
);
121+
it('should return empty array when N is 0', async function () {
122+
await heap.init(someValues);
123+
expect(await heap._topN_heap(0)).toEqual([]);
124+
});
125+
it('should return empty array when heap is empty', async function () {
126+
expect(await heap._topN_heap(5)).toEqual([]);
127+
});
121128
});
122129
describe('#_bottomN(N)', function () {
123130
it.each([1, 6, 12, someValues.length])(

0 commit comments

Comments
 (0)