1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import * as assert from 'assert';
|
18 | import { Container } from 'inversify';
|
19 | import { createTreeContainer, isTreeServices } from './tree-container';
|
20 | import { TreeSearch } from './tree-search';
|
21 | import { defaultTreeProps, TreeProps } from './tree-widget';
|
22 |
|
23 | describe('TreeContainer', () => {
|
24 | describe('IsTreeServices should accurately distinguish TreeProps from TreeContainerProps', () => {
|
25 | it('should assign search:boolean to TreeProps', () => {
|
26 | assert(isTreeServices({
|
27 | ...defaultTreeProps, search: true, multiSelect: true, globalSelection: true, contextMenuPath: ['so-contextual']
|
28 | }) === false);
|
29 | });
|
30 | it('should assign search:not-a-boolean to TreeContainerProps', () => {
|
31 | assert(isTreeServices({ search: TreeSearch }) === true);
|
32 | });
|
33 | const nonDefault = { search: !defaultTreeProps.search, contextMenu: ['no-default-for-this'] };
|
34 | it('should use props passed in as just props', () => {
|
35 | const parent = new Container();
|
36 | const child = createTreeContainer(parent, nonDefault);
|
37 | assert.deepStrictEqual(child.get(TreeProps), { ...defaultTreeProps, ...nonDefault });
|
38 | });
|
39 | it('should use props passed in as part of TreeContainerProps', () => {
|
40 | const parent = new Container();
|
41 | const child = createTreeContainer(parent, { props: nonDefault });
|
42 | assert.deepStrictEqual(child.get(TreeProps), { ...defaultTreeProps, ...nonDefault });
|
43 | });
|
44 | });
|
45 | });
|