More tests.

This commit is contained in:
Oleksii Trekhleb 2018-04-04 07:02:56 +03:00
parent 72baedeb89
commit f5ae2360f2
6 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
.idea .idea
coverage

5
jest.config.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
verbose: false,
collectCoverage: true,
coverageDirectory: './coverage/',
};

View File

@ -26,8 +26,10 @@ describe('PriorityQueue', () => {
priorityQueue.add(10, 1); priorityQueue.add(10, 1);
priorityQueue.add(5, 2); priorityQueue.add(5, 2);
priorityQueue.add(100, 0); priorityQueue.add(100, 0);
priorityQueue.add(200, 0);
expect(priorityQueue.poll()).toBe(100); expect(priorityQueue.poll()).toBe(100);
expect(priorityQueue.poll()).toBe(200);
expect(priorityQueue.poll()).toBe(10); expect(priorityQueue.poll()).toBe(10);
expect(priorityQueue.poll()).toBe(5); expect(priorityQueue.poll()).toBe(5);
}); });

View File

@ -46,6 +46,7 @@ describe('Queue', () => {
expect(queue.dequeue()).toBe(1); expect(queue.dequeue()).toBe(1);
expect(queue.dequeue()).toBe(2); expect(queue.dequeue()).toBe(2);
expect(queue.dequeue()).toBeNull();
expect(queue.isEmpty()).toBeTruthy(); expect(queue.isEmpty()).toBeTruthy();
}); });
}); });

View File

@ -46,6 +46,7 @@ describe('Stack', () => {
expect(stack.pop()).toBe(2); expect(stack.pop()).toBe(2);
expect(stack.pop()).toBe(1); expect(stack.pop()).toBe(1);
expect(stack.pop()).toBeNull();
expect(stack.isEmpty()).toBeTruthy(); expect(stack.isEmpty()).toBeTruthy();
}); });
}); });

View File

@ -99,5 +99,7 @@ describe('BinaryTreeNode', () => {
expect(rootNode.replaceChild(rootNode.right, replacementNode)).toBeTruthy(); expect(rootNode.replaceChild(rootNode.right, replacementNode)).toBeTruthy();
expect(rootNode.traverseInOrder()).toEqual([1, 2, 5]); expect(rootNode.traverseInOrder()).toEqual([1, 2, 5]);
expect(rootNode.replaceChild(new BinaryTreeNode(), new BinaryTreeNode())).toBeFalsy();
}); });
}); });