Code coverage report for spec/algo/11-sorting/mergeSort.spec.js

Statements: 100% (17 / 17)      Branches: 100% (0 / 0)      Functions: 100% (6 / 6)      Lines: 100% (17 / 17)      Ignored: none     

All files » spec/algo/11-sorting/ » mergeSort.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 301   1   1 1   1 4 4 4 4     1 1     1 1     1 1     1 1    
var mergeSort = require("../../../lib/algorithms/11-sorting/mergeSort.js");
 
describe('When using MergeSort on an unsorted Array', function () {
 
	var unsortedLength = null;
	var sortedArray = null;
 
	beforeEach(function() {
		var unsortedArray = [10, 8, 3, 1, 7, 5, 9, 6];
		unsortedLength = unsortedArray.length;
		mergeSort(unsortedArray, 0, unsortedArray.length - 1);
		sortedArray = unsortedArray;
	});
 
	it('the sorted array will not be null.', function () {
		expect(sortedArray).not.toBe(null);
	});
 
	it('a sorted array of the same length will be returned.', function () {
		expect(sortedArray.length).toEqual(unsortedLength);
	});
 
	it('the first element will be 1', function () {
		expect(sortedArray[0]).toEqual(1);
	});
 
	it('the last element will be 10', function () {
		expect(sortedArray[sortedArray.length - 1]).toEqual(10);
	});
});