-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathminStack.test.js
More file actions
38 lines (34 loc) · 1.14 KB
/
minStack.test.js
File metadata and controls
38 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { MinStack } = require('./minStack.js');
describe('MinStack', () => {
it('should Infinity for min on empty stack', () => {
const minStack = new MinStack();
expect(minStack.getMin()).toBe(Infinity);
});
it("should return Infinity for the top on empty stack", () => {
const minStack = new MinStack();
expect(minStack.top()).toBe(Infinity);
});
it("should correctly return the min value after a variety of numbers pushed to it", () => {
const minStack = new MinStack();
minStack.push(1);
minStack.push(2);
minStack.push(0);
minStack.pop();
minStack.push(-10);
minStack.push(10);
minStack.pop();
expect(minStack.getMin()).toBe(-10);
});
it("should correctly return the top after a variety of numbers pushed to it", () => {
const minStack = new MinStack();
minStack.push(1);
minStack.push(2);
minStack.push(0);
minStack.push(-100);
minStack.pop();
minStack.push(-5);
minStack.push(100);
minStack.pop();
expect(minStack.top()).toBe(-5);
});
});