add Tree class

This commit is contained in:
2017-11-20 09:26:13 +01:00
parent 7c8643b090
commit adda1c932a
13 changed files with 329 additions and 118 deletions

View File

@ -45,7 +45,7 @@ tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectm
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
testObjectmap.forEach(itemArg => {
expect(itemArg).have.ownProperty('propOne')
expect(itemArg).to.contain('propOne')
})
})
@ -61,7 +61,7 @@ tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () =>
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' }
testObjectmap.add(myObject)
let clonedArray = testObjectmap.getArray()
expect(clonedArray[ clonedArray.length - 1 ]).eql(myObject)
expect(clonedArray[ clonedArray.length - 1 ]).to.equal(myObject)
})
tap.test('should get one object and then remove it', async () => {

24
test/test.tree.ts Normal file
View File

@ -0,0 +1,24 @@
import { tap, expect } from 'tapbundle'
import * as lik from '../ts/index'
let testTree = new lik.Tree<TestClass>()
class TestClass {
constructor (public hey: string) {
// nothing here
}
}
let testInstance = new TestClass('first')
tap.test('create a valid tree instance', async () => {
testTree = new lik.Tree()
expect(testTree).to.be.instanceOf(lik.Tree)
})
tap.test('should insert an object', async () => {
testTree.initialize(testInstance)
let resultArray = testTree.treeToArray(testInstance, {})
expect(resultArray).to.contain(testInstance)
})
tap.start()