Code coverage report for spec/algo/4-binaryTrees/isRoute.spec.js

Statements: 100% (39 / 39)      Branches: 100% (0 / 0)      Functions: 100% (5 / 5)      Lines: 100% (39 / 39)      Ignored: none     

All files » spec/algo/4-binaryTrees/ » isRoute.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 541   1 1 1 1 1 1 1 1   1 3 3 3 3 3 3 3 3     3 3 3 3 3 3 3     3 3 3 3 3 3 3 3       1 1     1 1     1 1    
var isRoute = require("../../../lib/algorithms/4-binaryTrees/isRoute.js");
 
describe('When testing a directed graph, determine if there is a route', function () {
	var graph;
	var a;
	var b;
	var c;
	var d;
	var e;
	var f;
 
	beforeEach(function() {
		graph = { children: []};
		a = { data: "a", children: []};
		b = { data: "b", children: []};
		c = { data: "c", children: []};
		d = { data: "d", children: []};
		e = { data: "e", children: []};
		f = { data: "f", children: []};
		g = { data: "g", children: []};
 
		//add children to graph
		graph.children.push(a);
		graph.children.push(b);
		graph.children.push(c);
		graph.children.push(d);
		graph.children.push(e);
		graph.children.push(f);
		graph.children.push(g);
 
		//directed graph with one loop - c->e->d, and no path between a & g
		a.children.push(b);
		a.children.push(c);
		b.children.push(c);
		c.children.push(e);
		d.children.push(c);
		e.children.push(d);
		e.children.push(f);
		g.children.push(d);
 
	});
 
	it('A route can be found from a to f', function () {
		expect(isRoute(graph, a, f)).toBe(true);
	});
 
	it('A route can be found from g to f', function () {
		expect(isRoute(graph, g, f)).toBe(true);
	});
 
	it('No route exists between a and g', function () {
		expect(isRoute(graph, a, g)).toBe(false);
	});
});