[ARVADOS-WORKBENCH2] updated: 1.2.0-543-g8d07194
Git user
git at public.curoverse.com
Mon Oct 8 03:09:33 EDT 2018
Summary of changes:
src/models/tree.test.ts | 129 +++++++++++-----------
src/store/tree-picker/tree-picker-reducer.test.ts | 2 +-
2 files changed, 68 insertions(+), 63 deletions(-)
via 8d071942032d47e8553c8b4e711e9437712fea5b (commit)
from c1889cf297d64d0b7290660bdb074a73f1394b97 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 8d071942032d47e8553c8b4e711e9437712fea5b
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Mon Oct 8 09:08:59 2018 +0200
Update tree model tests
Feature #13862
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/models/tree.test.ts b/src/models/tree.test.ts
index 5cbab65..54b11d4 100644
--- a/src/models/tree.test.ts
+++ b/src/models/tree.test.ts
@@ -4,6 +4,7 @@
import * as Tree from './tree';
import { initTreeNode } from './tree';
+import { pipe } from 'lodash/fp';
describe('Tree', () => {
let tree: Tree.Tree<string>;
@@ -17,73 +18,77 @@ describe('Tree', () => {
expect(Tree.getNode('Node 1')(newTree)).toEqual(initTreeNode({ id: 'Node 1', value: 'Value 1' }));
});
- // it('adds new node reference to parent children', () => {
- // const [newTree] = [tree]
- // .map(Tree.setNode(mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' })))
- // .map(Tree.setNode(mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 2' })));
+ it('adds new node reference to parent children', () => {
+ const newTree = pipe(
+ Tree.setNode(initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' })),
+ Tree.setNode(initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 2' })),
+ )(tree);
- // expect(Tree.getNode('Node 1')(newTree)).toEqual({ children: ['Node 2'], id: 'Node 1', parent: '', value: 'Value 1' });
- // });
+ expect(Tree.getNode('Node 1')(newTree)).toEqual({
+ ...initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ children: ['Node 2']
+ });
+ });
- // it('gets node ancestors', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3', parent: 'Node 2', value: 'Value 1' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // expect(Tree.getNodeAncestorsIds('Node 3')(newTree)).toEqual(['Node 1', 'Node 2']);
- // });
+ it('gets node ancestors', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3', parent: 'Node 2', value: 'Value 1' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ expect(Tree.getNodeAncestorsIds('Node 3')(newTree)).toEqual(['Node 1', 'Node 2']);
+ });
- // it('gets node descendants', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // expect(Tree.getNodeDescendantsIds('Node 1')(newTree)).toEqual(['Node 2', 'Node 3', 'Node 2.1', 'Node 3.1']);
- // });
+ it('gets node descendants', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ expect(Tree.getNodeDescendantsIds('Node 1')(newTree)).toEqual(['Node 2', 'Node 3', 'Node 2.1', 'Node 3.1']);
+ });
- // it('gets root descendants', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // expect(Tree.getNodeDescendantsIds('')(newTree)).toEqual(['Node 1', 'Node 2', 'Node 3', 'Node 2.1', 'Node 3.1']);
- // });
+ it('gets root descendants', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ expect(Tree.getNodeDescendantsIds('')(newTree)).toEqual(['Node 1', 'Node 2', 'Node 3', 'Node 2.1', 'Node 3.1']);
+ });
- // it('gets node children', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // expect(Tree.getNodeChildrenIds('Node 1')(newTree)).toEqual(['Node 2', 'Node 3']);
- // });
+ it('gets node children', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ expect(Tree.getNodeChildrenIds('Node 1')(newTree)).toEqual(['Node 2', 'Node 3']);
+ });
- // it('gets root children', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // expect(Tree.getNodeChildrenIds('')(newTree)).toEqual(['Node 1', 'Node 3']);
- // });
+ it('gets root children', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2.1', parent: 'Node 2', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 3.1', parent: 'Node 3', value: 'Value 1' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ expect(Tree.getNodeChildrenIds('')(newTree)).toEqual(['Node 1', 'Node 3']);
+ });
- // it('maps tree', () => {
- // const newTree = [
- // mockTreeNode({ children: [], id: 'Node 1', parent: '', value: 'Value 1' }),
- // mockTreeNode({ children: [], id: 'Node 2', parent: 'Node 1', value: 'Value 2' }),
- // ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
- // const mappedTree = Tree.mapTreeValues<string, number>(value => parseInt(value.split(' ')[1], 10))(newTree);
- // expect(Tree.getNode('Node 2')(mappedTree)).toEqual({ children: [], id: 'Node 2', parent: 'Node 1', value: 2 });
- // });
+ it('maps tree', () => {
+ const newTree = [
+ initTreeNode({ id: 'Node 1', parent: '', value: 'Value 1' }),
+ initTreeNode({ id: 'Node 2', parent: 'Node 1', value: 'Value 2' }),
+ ].reduce((tree, node) => Tree.setNode(node)(tree), tree);
+ const mappedTree = Tree.mapTreeValues<string, number>(value => parseInt(value.split(' ')[1], 10))(newTree);
+ expect(Tree.getNode('Node 2')(mappedTree)).toEqual(initTreeNode({id: 'Node 2', parent: 'Node 1', value: 2 }));
+ });
});
diff --git a/src/store/tree-picker/tree-picker-reducer.test.ts b/src/store/tree-picker/tree-picker-reducer.test.ts
index b85e272..3a0b60e 100644
--- a/src/store/tree-picker/tree-picker-reducer.test.ts
+++ b/src/store/tree-picker/tree-picker-reducer.test.ts
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { createTree, getNodeValue, getNodeChildrenIds, getNode, TreeNodeStatus } from '~/models/tree';
+import { createTree, getNodeChildrenIds, getNode, TreeNodeStatus } from '~/models/tree';
import { pipe } from 'lodash/fp';
import { treePickerReducer } from "./tree-picker-reducer";
import { treePickerActions } from "./tree-picker-actions";
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list