-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHierarchyObjectTest.ts
52 lines (40 loc) · 1.1 KB
/
HierarchyObjectTest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-disable @typescript-eslint/no-explicit-any */
import "reflect-metadata";
import {Suite} from "mocha";
import {expect} from "chai";
import {MockHierarchyObject} from "./mock/mvc/MockHierarchyObject";
import {HierarchyObjectContainer, IHierarchyObject, IHierarchyObjectContainer} from "../src";
describe('HierarchyObjectTest', function (this: Suite)
{
let ho: IHierarchyObject;
beforeEach(() =>
{
ho = new MockHierarchyObject();
});
afterEach(() =>
{
if (!ho.isDisposed)
{
ho.dispose();
}
});
it('testDispose', () =>
{
addToContainer(ho);
ho.dispose();
expect(ho.isDisposed).true;
expect(ho.parent).not.exist;
});
it('testParent', () =>
{
expect(ho.parent).not.exist;
const hoc: IHierarchyObjectContainer = addToContainer(ho);
expect(ho.parent).equals(hoc);
});
});
export function addToContainer(ho: IHierarchyObject): IHierarchyObjectContainer
{
const hoc: IHierarchyObjectContainer = new HierarchyObjectContainer();
hoc.add(ho);
return hoc;
}