diff --git a/cosmoz-default-tree.html b/cosmoz-default-tree.html new file mode 100644 index 0000000..7458c72 --- /dev/null +++ b/cosmoz-default-tree.html @@ -0,0 +1,156 @@ + + diff --git a/cosmoz-tree.html b/cosmoz-tree.html index 3244e67..f685429 100644 --- a/cosmoz-tree.html +++ b/cosmoz-tree.html @@ -1,123 +1,77 @@ \ No newline at end of file + diff --git a/test/cosmoz-tree_test.html b/test/cosmoz-tree_test.html index 35a5ae1..5a646fd 100644 --- a/test/cosmoz-tree_test.html +++ b/test/cosmoz-tree_test.html @@ -1,38 +1,219 @@ - - - - - cosmoz-tree test - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + }); + + test('instantiating a Cosmoz.Tree works', function () { + assert.isNotNull(multiRootTree); + }); + + test('getNodeByProperty', function () { + var node2 = multiRootTree.getNodeByProperty('id', '167d1485-7d4f-4c7d-86cd-a4fb00f31245'), + node3 = multiRootTree.getNodeByProperty('id', '3a7654f1-e3e6-49c7-b6a8-a4fb00f31245'), + node4 = multiRootTree.getNodeByProperty('id', '2b547550-b874-4228-9395-a4fb00f31245'); + assert.isNotNull(node2); + assert.isNotNull(node3); + assert.isNotNull(node4); + + }); + + test('getPath', function () { + var + node2 = multiRootTree.getNodeByProperty('id', '167d1485-7d4f-4c7d-86cd-a4fb00f31245'), + node3 = multiRootTree.getNodeByProperty('id', '3a7654f1-e3e6-49c7-b6a8-a4fb00f31245'), + node4 = multiRootTree.getNodeByProperty('id', '2b547550-b874-4228-9395-a4fb00f31245'), + node2Path = multiRootTree.getPath(node2), + node3Path = multiRootTree.getPath(node3), + node4Path = multiRootTree.getPath(node4); + + assert.equal(node2Path.length, 1); + assert.equal(node2Path[0], node2); + + assert.equal(node3Path.length, 2); + assert.equal(node3Path[0], node2); + assert.equal(node3Path[1], node3); + + assert.equal(node4Path.length, 1); + assert.equal(node4Path[0], node4); + + }); + }); + + suite('missingAncestor', function () { + var missingAncestorFixture, + missingAncestorTree; + + suiteSetup(function (done) { + missingAncestorFixture = fixture('missingAncestor'); + missingAncestorFixture.addEventListener('response', function () { + missingAncestorTree = new Cosmoz.DefaultTree(missingAncestorFixture.lastResponse); + done(); + }); + }); + + test('instantiating a Cosmoz.Tree works', function () { + assert.isNotNull(missingAncestorTree); + }); + + test('getNodeByProperty', function () { + var node2 = missingAncestorTree.getNodeByProperty('id', '167d1485-7d4f-4c7d-86cd-a4fb00f31245'), + node301 = missingAncestorTree.getNodeByProperty('id', '3a7654f1-e3e6-49c7-b6a8-a4fb00f31245'), + node401 = missingAncestorTree.getNodeByProperty('id', '865065da-f44c-472e-a8df-a4fb00f3124b'); + assert.isNotNull(node2); + assert.isNotNull(node301); + assert.isNotNull(node401); + + }); + + test('getPath', function () { + var + node301 = missingAncestorTree.getNodeByProperty('id', '3a7654f1-e3e6-49c7-b6a8-a4fb00f31245'), + node401 = missingAncestorTree.getNodeByProperty('id', '865065da-f44c-472e-a8df-a4fb00f3124b'), + node301Path = missingAncestorTree.getPath(node301), + node401Path = missingAncestorTree.getPath(node401); + + assert.equal(node301Path.length, 1); + assert.equal(node301Path[0], node301); + + assert.equal(node401Path.length, 2); + assert.equal(node401Path[0], node301); + assert.equal(node401Path[1], node401); + + }); + }); + }()); + diff --git a/test/data/basicTree.json b/test/data/basicTree.json new file mode 100644 index 0000000..9b19399 --- /dev/null +++ b/test/data/basicTree.json @@ -0,0 +1,38 @@ +{ + "1": { + "id": "11111111-1111-1111-1111-111111111111", + "name": "Root", + "pathLocator": "1", + "children": { + "2": { + "id": "167d1485-7d4f-4c7d-86cd-a4fb00f31245", + "name": "Node2", + "pathLocator": "1.2", + "children": { + "3": { + "id": "3a7654f1-e3e6-49c7-b6a8-a4fb00f31245", + "name": "Node3", + "pathLocator": "1.2.3", + "children": { + "301": { + "id": "3a7654f1-e3e6-49c7-b6a8-a4fb00f31245", + "name": "Node301", + "pathLocator": "1.2.3.301", + "children": { + + } + } + } + } + } + }, + "4": { + "id": "2b547550-b874-4228-9395-a4fb00f31245", + "name": "Node4", + "pathLocator": "1.4", + "children": {} + } + } + } +} + diff --git a/test/data/missingAncestorTree.json b/test/data/missingAncestorTree.json new file mode 100644 index 0000000..a35104f --- /dev/null +++ b/test/data/missingAncestorTree.json @@ -0,0 +1,24 @@ +{ + "2": { + "id": "167d1485-7d4f-4c7d-86cd-a4fb00f31245", + "name": "Node2", + "pathLocator": "1.2", + "children": {} + }, + + "301": { + "id": "3a7654f1-e3e6-49c7-b6a8-a4fb00f31245", + "name": "Node301", + "pathLocator": "1.2.3.301", + "children": { + "401": { + "id": "865065da-f44c-472e-a8df-a4fb00f3124b", + "name": "Node401", + "pathLocator": "1.2.3.301.401", + "children": { + } + + } + } + } +} diff --git a/test/data/multiRootTree.json b/test/data/multiRootTree.json new file mode 100644 index 0000000..6e0f355 --- /dev/null +++ b/test/data/multiRootTree.json @@ -0,0 +1,22 @@ +{ + + "2": { + "id": "167d1485-7d4f-4c7d-86cd-a4fb00f31245", + "name": "Node2", + "pathLocator": "1.2", + "children": { + "3": { + "id": "3a7654f1-e3e6-49c7-b6a8-a4fb00f31245", + "name": "Node3", + "pathLocator": "1.2.3", + "children": {} + } + } + }, + "4": { + "id": "2b547550-b874-4228-9395-a4fb00f31245", + "name": "Node4", + "pathLocator": "1.4", + "children": {} + } +} diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..b8a6654 --- /dev/null +++ b/test/index.html @@ -0,0 +1,18 @@ + + + + + + cosmoz-bottom-bar tests + + + + + + +