feat(router): add UrlSegment, RouteSegment, and Tree

This commit is contained in:
vsavkin
2016-04-22 12:04:27 -07:00
committed by Victor Savkin
parent 3e114227f8
commit 90a1f7d5c4
2 changed files with 109 additions and 0 deletions
@@ -0,0 +1,43 @@
import {
ComponentFixture,
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
ddescribe,
xdescribe,
describe,
el,
expect,
iit,
inject,
beforeEachProviders,
it,
xit
} from 'angular2/testing_internal';
import {Tree} from 'angular2/src/alt_router/segments';
export function main() {
describe('tree', () => {
it("should return the root of the tree", () => {
let t = new Tree<any>([1, 2, 3]);
expect(t.root).toEqual(1);
});
it("should return the parent of a node", () => {
let t = new Tree<any>([1, 2, 3]);
expect(t.parent(1)).toEqual(null);
expect(t.parent(2)).toEqual(1);
});
it("should return the children of a node", () => {
let t = new Tree<any>([1, 2, 3]);
expect(t.children(1)).toEqual([2]);
});
it("should return the path to the root", () => {
let t = new Tree<any>([1, 2, 3]);
expect(t.pathToRoot(2)).toEqual([1, 2]);
});
});
}