From 5fceb2154942a86d6b3a7575c960e55f5dc00328 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Tue, 2 Aug 2016 13:41:02 -0700 Subject: [PATCH] refactor(router): remove dead code --- modules/@angular/router/src/utils/tree.ts | 14 -------------- .../@angular/router/test/utils/tree.spec.ts | 19 ------------------- 2 files changed, 33 deletions(-) diff --git a/modules/@angular/router/src/utils/tree.ts b/modules/@angular/router/src/utils/tree.ts index a019cab707..755a2a17ae 100644 --- a/modules/@angular/router/src/utils/tree.ts +++ b/modules/@angular/router/src/utils/tree.ts @@ -38,8 +38,6 @@ export class Tree { } pathFromRoot(t: T): T[] { return findPath(t, this._root, []).map(s => s.value); } - - contains(tree: Tree): boolean { return contains(this._root, tree._root); } } function findNode(expected: T, c: TreeNode): TreeNode { @@ -64,18 +62,6 @@ function findPath(expected: T, c: TreeNode, collected: TreeNode[]): Tre return []; } -function contains(tree: TreeNode, subtree: TreeNode): boolean { - if (tree.value !== subtree.value) return false; - - for (let subtreeNode of subtree.children) { - const s = tree.children.filter(child => child.value === subtreeNode.value); - if (s.length === 0) return false; - if (!contains(s[0], subtreeNode)) return false; - } - - return true; -} - export class TreeNode { constructor(public value: T, public children: TreeNode[]) {} diff --git a/modules/@angular/router/test/utils/tree.spec.ts b/modules/@angular/router/test/utils/tree.spec.ts index 65a534ea4f..311ddccdc5 100644 --- a/modules/@angular/router/test/utils/tree.spec.ts +++ b/modules/@angular/router/test/utils/tree.spec.ts @@ -43,23 +43,4 @@ describe('tree', () => { const t = new Tree(new TreeNode(1, [new TreeNode(2, [])])); expect(t.pathFromRoot(2)).toEqual([1, 2]); }); - - describe('contains', () => { - it('should work', () => { - const tree = new Tree( - new TreeNode(1, [new TreeNode(2, []), new TreeNode(3, [])])); - const subtree1 = new Tree(new TreeNode(1, [])); - const subtree2 = new Tree(new TreeNode(1, [new TreeNode(2, [])])); - const subtree3 = new Tree(new TreeNode(1, [new TreeNode(3, [])])); - const notSubtree1 = new Tree(new TreeNode(1, [new TreeNode(4, [])])); - const notSubtree2 = new Tree( - new TreeNode(1, [new TreeNode(2, [new TreeNode(4, [])])])); - - expect(tree.contains(subtree1)).toEqual(true); - expect(tree.contains(subtree2)).toEqual(true); - expect(tree.contains(subtree3)).toEqual(true); - expect(tree.contains(notSubtree1)).toEqual(false); - expect(tree.contains(notSubtree2)).toEqual(false); - }); - }); });