Code coverage report for spec/algo/2-linkedLists/partition.spec.js

Statements: 100% (30 / 30)      Branches: 100% (4 / 4)      Functions: 100% (3 / 3)      Lines: 100% (30 / 30)      Ignored: none     

All files » spec/algo/2-linkedLists/ » partition.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 421 1   1 1 1 1   1 1 1 1 1 1 1 1 1 1 1 1 1     1 1 1   1 11 6 5 1   4     11 11        
var partition = require("../../../lib/algorithms/2-linkedLists/partition.js");
var LinkedList = require("../../../lib/dataStructures/linkedList.js");
 
describe('When using partition(10) on a linked list of integers', function () {
	var list;
	var noDupes;
	var number = 10;
 
	beforeEach(function() {
		list = new LinkedList();
		list.add(1);
		list.add(2);
		list.add(10);
		list.add(3);
		list.add(40);
		list.add(4);
		list.add(14);
		list.add(5);
		list.add(16);
		list.add(6);
		list.add(69);
	});
 
	it('all the numbers under ' + number + ' will be before numbers greater than ' + number, function () {
		var result = partition(list.start, number);
		var lessThanX = 0;
 
		while (result != null) {
			if(lessThanX < 6){
				expect(result.data).toBeLessThan(number);
			} else if(lessThanX === 6) {
				expect(result.data).toEqual(number);
			} else {
				expect(result.data).toBeGreaterThan(number);
			}
 
			lessThanX++;
			result = result.next;
		}
	});
 
});