Code coverage report for spec/dataStructures/trie.sort.spec.js

Statements: 100% (43 / 43)      Branches: 100% (0 / 0)      Functions: 100% (8 / 8)      Lines: 100% (43 / 43)      Ignored: none     

All files » spec/dataStructures/ » trie.sort.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 631     1 1 1 1 1 1   1 1 1 1 1 1     1 1     1 1   1 1 1 1 1         1 1 1 1 1 1   1 1 1 1 1 1     1 1     1 1   1 1 1 1 1    
var trie = require("../../lib/dataStructures/trie.js");
 
 
describe('Given a trie containing the words "free", "freed", "freedom", and "frees"', function() {
	var tree;
	var testValue1 = "free";
	var testValue2 = "freed";
	var testValue3 = "frees";
	var testValue5 = "freedom";
 
	beforeEach(function() {
		tree = new trie();
		tree.add(testValue1);
		tree.add(testValue2);
		tree.add(testValue3);
		tree.add(testValue5);
	});
 
	afterEach(function() {
		tree = null;
	});
 
	it('the sort() method will return a sorted list of strings in the correct order', function() {
		var sorted = tree.sort();
 
		expect(sorted.length).toBe(4);
		expect(sorted[0]).toBe(testValue1);
		expect(sorted[1]).toBe(testValue2);
		expect(sorted[2]).toBe(testValue5);
		expect(sorted[3]).toBe(testValue3);
	})
});
 
 
describe('Given a trie containing the words "apple", "banana", "cherry", and "fejoya"', function() {
	var tree;
	var testValue1 = "apple";
	var testValue2 = "banana";
	var testValue3 = "cherry";
	var testValue5 = "fejoya";
 
	beforeEach(function() {
		tree = new trie();
		tree.add(testValue1);
		tree.add(testValue2);
		tree.add(testValue3);
		tree.add(testValue5);
	});
 
	afterEach(function() {
		tree = null;
	});
 
	it('the sort() method will return a sorted list of strings in the correct order', function() {
		var sorted = tree.sort();
 
		expect(sorted.length).toBe(4);
		expect(sorted[0]).toBe(testValue1);
		expect(sorted[1]).toBe(testValue2);
		expect(sorted[2]).toBe(testValue3);
		expect(sorted[3]).toBe(testValue5);
	})
});