implement JSON methods for tree
This commit is contained in:
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user