Code coverage report for spec/dataStructures/stack.two.spec.js

Statements: 100% (48 / 48)      Branches: 100% (0 / 0)      Functions: 100% (14 / 14)      Lines: 100% (48 / 48)      Ignored: none     

All files » spec/dataStructures/ » stack.two.spec.js
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 811   1 1 1 1   1 1 1 1       1 1     1 1         1 1 1 1   1 2 2 2     1 2     1 1 1     1 1 1         1 1 1 1   1 2 2 2     1 2     1 1 1 1     1 1 1 1 1        
var stack = require("../../lib/dataStructures/stack.js");
 
describe('When pushing two elements to a stack', function () {
	var myStack;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myStack = new stack();
		myStack.push(testValue1);
		myStack.push(testValue2);
 
	});
 
	afterEach(function() {
		myStack = null;
	});
 
	it('the stack`s length should be 2', function () {
		expect(myStack.length).toBe(2);
	});
 
});
 
describe('When pushing two elements to a stack and then popping an element', function () {
	var myStack;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myStack = new stack();
		myStack.push(testValue1);
		myStack.push(testValue2);
	});
 
	afterEach(function() {
		myStack = null;
	});
 
	it('the stack`s length should be 1', function () {
		var result = myStack.pop();
		expect(myStack.length).toBe(1);
	});
 
	it('the element popped should be the last element added.', function () {
		var result = myStack.pop();
		expect(result).toBe(testValue2);
	});
 
});
 
describe('When pushing two elements to a stack and then popping 2 elements', function () {
	var myStack;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myStack = new stack();
		myStack.push(testValue1);
		myStack.push(testValue2);
	});
 
	afterEach(function() {
		myStack = null;
	});
 
	it('the stack`s length should be 0', function () {
		myStack.pop();
		myStack.pop();
		expect(myStack.length).toBe(0);
	});
 
	it('the elements popped should be in the inverse order to which they were added.', function () {
		var result1 = myStack.pop();
		var result2 = myStack.pop();
		expect(result1).toBe(testValue2);
		expect(result2).toBe(testValue1);
	});
 
});