implement JSON methods for tree

This commit is contained in:
2018-08-31 17:24:35 +02:00
parent e81e0ebd41
commit 6aff4c9031
7 changed files with 380 additions and 219 deletions

View File

@ -1,7 +1,7 @@
// import test framework
import { expect, tap } from '@pushrocks/tapbundle';
import * as events from 'events';
import * as smartq from 'smartq';
import * as smartpromise from '@pushrocks/smartpromise';
// import the module
import * as lik from '../ts/index';

View File

@ -1,7 +1,7 @@
// import test framework
import { expect, tap } from '@pushrocks/tapbundle';
import * as events from 'events';
import * as smartq from 'smartq';
import * as smartpromise from '@pushrocks/smartpromise';
// import the module
import * as lik from '../ts/index';

View File

@ -1,7 +1,7 @@
// import test framework
import { expect, tap } from '@pushrocks/tapbundle';
import * as events from 'events';
import * as smartq from 'smartq';
import * as smartpromise from '@pushrocks/smartpromise';
// import the module
import * as lik from '../ts/index';

View File

@ -1,14 +1,20 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as lik from '../ts/index';
let testTree = new lik.Tree<TestClass>();
class TestClass {
constructor(public hey: string) {
// nothing here
}
}
let testTree = new lik.Tree<TestClass>();
let testInstance = new TestClass('first');
let testInstance2 = new TestClass('second');
let testInstance3 = new TestClass('third');
let testInstance4 = new TestClass('fourth');
let testInstance5 = new TestClass('fifth');
let testInstance6 = new TestClass('sixth');
tap.test('create a valid tree instance', async () => {
testTree = new lik.Tree();
@ -21,4 +27,14 @@ tap.test('should insert an object', async () => {
expect(resultArray).to.contain(testInstance);
});
tap.test('should add other objects in a hierachy', async () => {
testTree.appendChild(testInstance, testInstance2);
testTree.appendChild(testInstance, testInstance3);
testTree.appendChild(testInstance, testInstance4);
})
tap.test('should create a JSON object that reflects a tree\'s hierachy', async () => {
const jsonTreet = testTree.toJsonWithHierachy(testInstance);
});
tap.start();