add Tree class
This commit is contained in:
@ -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
24
test/test.tree.ts
Normal 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()
|
Reference in New Issue
Block a user