-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.spec.ts
More file actions
31 lines (26 loc) · 951 Bytes
/
Stack.spec.ts
File metadata and controls
31 lines (26 loc) · 951 Bytes
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
import { Stack } from "./Stack";
describe('Stack: ', () => {
describe('Fails when trying to: ', () => {
var collection = new Stack<number>();
it('get item from empty stack', () => {
expect(() => collection.pop()).toThrow(Error);
});
});
describe('Succed when trying to: ',()=>{
it('create a new item onto the end of the stack', ()=>{
var collection = new Stack<number>();
collection.push(1);
expect(collection.lenght).toBe(1);
expect(collection.pop()).toBe(1);
})
it('validates the amount of items after poping the last one', ()=>{
var collection = new Stack<number>();
collection.push(5);
collection.push(10);
collection.push(15);
let value = collection.pop();
expect(value).toBe(15);
expect(collection.lenght).toBe(2);
})
})
});