Code coverage report for spec/dataStructures/queue.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/ » queue.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 Queue = require("../../lib/dataStructures/queue.js");
 
describe('When adding two elements to a Queue', function () {
	var myQueue;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myQueue = new Queue();
		myQueue.add(testValue1);
		myQueue.add(testValue2);
 
	});
 
	afterEach(function() {
		myQueue = null;
	});
 
	it('the Queue`s length should be 2', function () {
		expect(myQueue.length).toBe(2);
	});
 
});
 
describe('When adding two elements to a Queue and then removing an element', function () {
	var myQueue;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myQueue = new Queue();
		myQueue.add(testValue1);
		myQueue.add(testValue2);
	});
 
	afterEach(function() {
		myQueue = null;
	});
 
	it('the Queue`s length should be 1', function () {
		var result = myQueue.remove();
		expect(myQueue.length).toBe(1);
	});
 
	it('the element removed should be the first element added.', function () {
		var result = myQueue.remove();
		expect(result).toBe(testValue1);
	});
 
});
 
describe('When adding two elements to a Queue and then removing 2 elements', function () {
	var myQueue;
	var testValue1 = "test_string1"
	var testValue2 = "test_string2"
 
	beforeEach(function() {
		myQueue = new Queue();
		myQueue.add(testValue1);
		myQueue.add(testValue2);
	});
 
	afterEach(function() {
		myQueue = null;
	});
 
	it('the Queue`s length should be 0', function () {
		myQueue.remove();
		myQueue.remove();
		expect(myQueue.length).toBe(0);
	});
 
	it('the elements removed should be in the order to which they were added.', function () {
		var result1 = myQueue.remove();
		var result2 = myQueue.remove();
		expect(result1).toBe(testValue1);
		expect(result2).toBe(testValue2);
	});
 
});