Skip to content

Commit

Permalink
refactor(tests): update the tests to accomdate the new constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledosama999 committed Mar 1, 2021
1 parent 1417814 commit 359ef7d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/functionalty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand All @@ -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 = [];

Expand All @@ -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 = [];

Expand All @@ -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 = [];

Expand All @@ -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 = [];

Expand All @@ -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 = [];
Expand Down

0 comments on commit 359ef7d

Please sign in to comment.