Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
trekhleb committed Apr 4, 2018
1 parent 72baede commit f5ae236
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.idea
coverage
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
verbose: false,
collectCoverage: true,
coverageDirectory: './coverage/',
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ describe('PriorityQueue', () => {
priorityQueue.add(10, 1);
priorityQueue.add(5, 2);
priorityQueue.add(100, 0);
priorityQueue.add(200, 0);

expect(priorityQueue.poll()).toBe(100);
expect(priorityQueue.poll()).toBe(200);
expect(priorityQueue.poll()).toBe(10);
expect(priorityQueue.poll()).toBe(5);
});
Expand Down
1 change: 1 addition & 0 deletions src/data-structures/queue/__test__/Queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Queue', () => {

expect(queue.dequeue()).toBe(1);
expect(queue.dequeue()).toBe(2);
expect(queue.dequeue()).toBeNull();
expect(queue.isEmpty()).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions src/data-structures/stack/__test__/Stack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Stack', () => {

expect(stack.pop()).toBe(2);
expect(stack.pop()).toBe(1);
expect(stack.pop()).toBeNull();
expect(stack.isEmpty()).toBeTruthy();
});
});
2 changes: 2 additions & 0 deletions src/data-structures/tree/__test__/BinaryTreeNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ describe('BinaryTreeNode', () => {

expect(rootNode.replaceChild(rootNode.right, replacementNode)).toBeTruthy();
expect(rootNode.traverseInOrder()).toEqual([1, 2, 5]);

expect(rootNode.replaceChild(new BinaryTreeNode(), new BinaryTreeNode())).toBeFalsy();
});
});

0 comments on commit f5ae236

Please sign in to comment.