Skip to content

Instantly share code, notes, and snippets.

@hawaijar
Created August 24, 2022 08:12
Show Gist options
  • Save hawaijar/d6d4f0325b84e296bd6c764c3670341b to your computer and use it in GitHub Desktop.
Save hawaijar/d6d4f0325b84e296bd6c764c3670341b to your computer and use it in GitHub Desktop.
MinHeap Test cases
import { MinHeap } from "../MinHeap";
const minHeap = new MinHeap();
describe("Testing MinHeap", () => {
minHeap.clearHeap();
let array = [30, 1, 2, 5, 7, 10, 20, 11, 1, 22, 2, 5, 17, 10, 20, -11];
minHeap.buildHeapFromArray(array);
let sortedArray = array.sort((a, b) => a - b);
for (const number of sortedArray) {
it(`should return ${number}`, () => {
expect(minHeap.poll()).toBe(number);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment