mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +08:00
More tests.
This commit is contained in:
parent
72baedeb89
commit
f5ae2360f2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
.idea
|
||||
coverage
|
||||
|
5
jest.config.js
Normal file
5
jest.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
verbose: false,
|
||||
collectCoverage: true,
|
||||
coverageDirectory: './coverage/',
|
||||
};
|
@ -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);
|
||||
});
|
||||
|
@ -46,6 +46,7 @@ describe('Queue', () => {
|
||||
|
||||
expect(queue.dequeue()).toBe(1);
|
||||
expect(queue.dequeue()).toBe(2);
|
||||
expect(queue.dequeue()).toBeNull();
|
||||
expect(queue.isEmpty()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -46,6 +46,7 @@ describe('Stack', () => {
|
||||
|
||||
expect(stack.pop()).toBe(2);
|
||||
expect(stack.pop()).toBe(1);
|
||||
expect(stack.pop()).toBeNull();
|
||||
expect(stack.isEmpty()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user